为了进行调查,我需要知道硬编码值的存储位置。硬编码值存储在哪里?
问题:一个函数里面有硬编码的值,这个函数被许多线程同时调用,这个硬编码值是否有可能被破坏。
例如:myFunc被多个线程同时调用。 可以字面“未处理的异常:”被破坏
void myFunc()
{
EXCEPTION_RECORD ExceptRec
bool retValue=doSomething(ExceptRec);
if(!retValue)
{
log ("Unhandled exception:"<< " code = " << hex << ExceptRec.ExceptionCode
<< " flags = " << ExceptRec.ExceptionFlags
<< " address = " << ExceptRec.ExceptionAddress)
// log is macro which will insert content into ostrstream
}
}
功能DoSomething的样子:
bool doSomething(EXCEPTION_RECORD &ExceptRec)
{
__try
{
// some code here
}
__except (ExceptRec = *(GetExceptionInformation())->ExceptionRecord,
EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
return true;
}
谢谢安德鲁,“如果你不锁定/同步”我的日志记录的东西是线程安全的,但任何如何字符串文字被损坏导致崩溃:( – Satbir 2009-10-06 05:29:34
@Soni:真的,我怀疑,否则你会不会得到错误,但是如果没有log(x)的定义很难说, – 2009-10-06 08:06:36