我在使用C++编写的应用程序中使用GCC 4.3.2编译了段错误问题。它在Debian 5 x64下运行。这个堆栈跟踪可能意味着什么?
方法坠毁在下面的代码行:
#0 0x00000000007c720f in Action::LoadInfoFromDB (this=0x7fae10d38d90)
at ../../../src/server/Action.cpp:1233
1233 m_tmap[tId]->slist[sId] = pItem;
,我从核心转储得到堆栈跟踪如下:
#0 0x00000000007c720f in Action::LoadInfoFromDB (this=0x7fae10d38d90)
at ../../../src/server/Action.cpp:1233
ItemGuid = <value optimized out>
ItemEntry = <value optimized out>
pItem = (class Item *) 0x2b52bae0
fields = <value optimized out>
tId = 1 '\001'
sId = 0 '\0'
result = (QueryResult *) 0x7fadcae3d8e0
#1 0x00000000007c7584 in Action::DisplayInfo (this=0x0, session=0x7fadbdd44a20)
at ../../../src/server/Action.cpp:1090
data = {<ByteBuffer> = {static DEFAULT_SIZE = 4096, _rpos = 220043248, _wpos = 5469086,
_storage = {<std::_Vector_base<unsigned char, std::allocator<unsigned char> >> = {
_M_impl = {<std::allocator<unsigned char>> = {<__gnu_cxx::new_allocator<unsigned char>> = {<No data fields>}, <No data fields>}, _M_start = 0x41200000 <Address 0x41200000 out of bounds>,
_M_finish = 0x0,
_M_end_of_storage = 0x7fad00000000 <Address 0x7fad00000000 out of bounds>}}, <No data fields>}}, m_code = 51152}
#2 0x00000000007d01a3 in Session::HandleAction (this=0x7fadbdd44a20,
[email protected]) at ../../../src/server/ActionHandler.cpp:862
pAction = (Action *) 0x0
ActionId = 1079
GoGuid = <value optimized out>
在帧#1,Action::DisplayInfo
被称为从Session::HandleAction
在pAction
。但帧#1显示this=0x0
,帧#2显示pAction = (Action *) 0x0
。
我不明白为什么这会导致崩溃。这可能意味着什么? DisplayInfo
无法在空引用上调用!
任何帮助最受赞赏。
感谢
为什么不呢?很明显,你确实把它称为空引用。你自己说,pAction =(Action *)0x0。 了解有关的代码可能会有所帮助。 – oefe 2010-01-23 12:49:38
@oefe:DisplayInfo似乎在空引用上调用,但看到帧#0。 DisplayInfo在同一个对象上调用它。这意味着DisplayInfo工作得很好。帧#0和帧#1应该在同一个对象上。 – 2010-01-23 12:52:23
如果您调用NULL对象指针的方法,C++不会生成任何类型的异常。它只会盲目地去做。 – 2010-01-23 13:03:17