下面的代码获取最后一行赛格故障:赛格故障做新的向量<string>
HookAct *act = new HookAct;
act->hkAct = HookAct::PRINT;
act->params = new vector<string>;
Valgrind的告诉我:
==15551== Process terminating with default action of signal 11 (SIGSEGV)
==15551== Access not within mapped region at address 0x0
==15551== at 0x5927026: std::string::assign(char const*, unsigned long) (in /usr/lib/libstdc++.so.6.0.10)
==15551== by 0x725424A: test (test.cpp:10)
没有人有任何想法,为什么它这样做呢?
仅供参考,这里的[电流,临时性] HookAct的定义:
struct HookAct {
enum {
PRINT
} hkAct;
vector<string> *params;
};
没有什么错你贴的代码块。错误的原因可能在代码中的其他地方。 – casablanca 2010-12-14 00:15:00
不能与给定的代码重复。 – 2010-12-14 00:17:30
是的,这个问题似乎是你实际赋予行为 - >参数值的地方。你有没有像'act-> params =“somestring”''在某个地方? – terminus 2010-12-14 00:17:42