这个堆栈跟踪可能意味着什么?
我在使用 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,
recv_data=@0x25d83780) at ../../../src/server/ActionHandler.cpp:862
pAction = (Action *) 0x0
ActionId = 1079
GoGuid = <value optimized out>
在帧 #1 中,从 Session::HandleAction 调用
在 Action::DisplayInfo
pAction
上。但是,第 1 帧显示 this=0x0
,第 2 帧显示 pAction = (Action *) 0x0
。
我不明白为什么这会导致崩溃。这可能意味着什么?无法在空引用上调用 DisplayInfo
!
非常感谢任何帮助。
谢谢
I'm having segfault problem in my application written using C++ and compiled using GCC 4.3.2. It is running under Debian 5 x64.
The process crashed on the following line of code:
#0 0x00000000007c720f in Action::LoadInfoFromDB (this=0x7fae10d38d90)
at ../../../src/server/Action.cpp:1233
1233 m_tmap[tId]->slist[sId] = pItem;
The stack trace that i got from the core dump is as follows:
#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,
recv_data=@0x25d83780) at ../../../src/server/ActionHandler.cpp:862
pAction = (Action *) 0x0
ActionId = 1079
GoGuid = <value optimized out>
In frame #1, Action::DisplayInfo
was called from Session::HandleAction
on pAction
. However frame #1 shows this=0x0
, and frame #2 shows pAction = (Action *) 0x0
.
I can't understand why this caused a crash. What does this possibly mean? DisplayInfo
can't be called on a null reference !
Any help is most appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是崩溃位置,那么您很可能正在索引不存在的数据。如果 m_tmap 是
std::map
就可以了 - 但您是否验证了slist[sId]
是有效的下标?或者,您在 NULL(或其他无效)指针上调用了成员函数,并在第一次直接访问对象的成员时崩溃,即使它距离几帧远。您确定
pAction
不能为NULL吗?堆栈跟踪不一定是有效的。首先,您可能会在应用程序中损坏它们。其次,优化编译器优化得太多,导致堆栈跟踪结果不可靠。尝试在禁用编译器优化的情况下进行构建,并使用
assert
来验证您的数组下标是否正常。If that's the crash position, you're most likely indexing into non-existent data. If m_tmap is a
std::map
it's ok - but did you verifyslist[sId]
is a valid subscript?Or - you called a member function on a NULL (or otherwise invalid)-Pointer and crash the first time you're accessing a member of the object directly, even if it's a few frames away. Are you sure
pAction
can't be NULL?Stack traces needn't be valid. Firstly, you can corrupt them in your application. Secondly, optimizing compilers optimize that much away that the resulting stack traces are not reliable. Try a build with compiler optimizations disabled and use
assert
to verify your array subscripting is ok.很明显,pAction 为空,并且您调用了 pAction->DisplayInfo。看看Action中的地址如何在第1帧中全部无效。除此之外,如果不看一些代码,很难说出原因,但我猜DisplayInfo直接或间接调用了LoadInfoFromDB。
It's pretty obvious that pAction is null, and you called pAction->DisplayInfo. Look at how the addresses in Action are all invalid in frame 1. Other than that, it's hard to tell why without seeing some code, but I guess DisplayInfo calls LoadInfoFromDB either directly or indirectly.