(5) 0x1c6235e1 in ProxyClass::Method_C (this=0xb3a0c8, sendFilePath=...) at ./src/ProxyClass.cpp:112
(6) 0x2c8706c1 in Class1::Method_B (this=0x1fc5a1, profile=0x2c8f2340 "fileProfile1", filePathAndFileName=0x0) at ./src/Class1.cpp:860
(7) 0x2c4ae4c0 in Method_B (profile=0x42c <Address 0x42c out of bounds>, filePathAndFileName=0x0) at ./src/Class1_interface.cpp:310
(8) 0x2c1e5c3c in Method_A (profile=0x42c <Address 0x42c out of bounds>, filename=0x2c601c1c "/tmp/temporaryfile.tmp") at ./src/file.cpp:890
我有上面使用gnu gdb调试的核心文件片段。此核心文件是在运行Linux的嵌入式系统上创建的。函数调用中没有对变量的操作...
我的问题如下:
为什么配置文件在第8帧看起来像Address 0x42c out of bounds
,而在第9帧之前没有对配置文件进行任何更改,这怎么会变得有意义(“fileSchema”)?
我的嵌入式系统崩溃,因为filename(char *)
等于0x2c601c1c
,并且路径在第8帧“/tmp/temporaryfile.tmp”上打印如下。但是,再次没有对filename变量的操作,Method_A调用Method_B但是char指针在第7帧突然变为null(filePathAndFileName = 0x0)。然后,我的系统崩溃了。如何通过操作将char *指针转换为NULL?
崩溃发生在第6帧,因为在Class1::Method_B
中执行了以下行"std::string filePath( filePathAndFileName);"
。正在尝试将null char指针初始化为字符串,我认为它会导致崩溃和Abort信号(程序以信号6终止,Aborted。)。如何避免char *在方法之间的变量传递中变为null?知道为什么它变成了空吗?
static TUint16 Method_A(char* profile, char* filename)
{
TUint16 a; //after the call of Method_B,the other part of this method being processed but anyway the code never passes to there because of th crash..
Method_B(profile,filename);
...
...
...
return a;
}
unsigned char Method_B_interface(char* profile, char* filePathAndFileName)
{
unsigned char returnValue = 0;
if ( callbackObject->Method_B( profile, filePathAndFileName ) )
{
returnValue = 1;
}
return returnValue;
}
bool Class1::Method_B(char* profile, char* filePathAndFileName)
{
bool returnValue = true;
std::string filePathString( filePathAndFileName );
std::string profileString( profile );
if(profileString == "fileProfile1")
{
if(xClass != NULL)
{
returnValue = xClass->Method_C(filePathString);
}
}
...
...
...
return returnValue;
}
bool ProxyClass::Method_C(const std::string& exportFilePathAndFileName)
{
bool returnValue;
std::string message = "dummy", parameters;
Serializer::serialize( message, exportFilePathAndFileName );
proxyRequest->synchCall( message, parameters );
getResponse(parameters);
Serializer::deserialize( parameters, returnValue );
return returnValue;
}