0

我有一个核心转储,它显示参考地址为 NULL....

细节:

(gdb) bt
#0  0xffffe410 in __kernel_vsyscall ()
#1  0x005b6c10 in raise () from /lib/libc.so.6
#2  0x005b8521 in abort () from /lib/libc.so.6
#3  0xf749e641 in Application::fatalSignal () at Application.cc:277
#4  <signal handler called>
#5  SdlProcess::procedureReturn (this=0x0, aSignal=0, aArg1=1, aArg2=0x0)
    at /include/c++/4.1.1/bits/stl_list.h:652
#6  0x08112edb in Sdl::authFailurer (aSdlProcess=@0x0, aLabel=0, aSignal=0, arg2=0x0) at /Mgr/SdlAuth.cc:1781
#7  0x00000000 in ?? ()
================
define:
Sdl::authFailurer(SdlProcess& aSdlProcess, int aLabel, int aSignal, int /*arg1*/, void* arg2)

#5 aSdlProcess.procedureReturn(0, 1, 0);

并在 stl_list.h:652

 bool empty() const

      { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }    ---->652
in procedureReturn()
{
   ...
  if (!mProcedureStack.empty())---->here,mProcedureStack is a datamember of SdlProcess
   ...
  {
  ...}
}
4

2 回答 2

1

您可以通过取消引用 NULL 指针来获得 NULL 引用。我不确定在这种特殊情况下如何发生这种情况,除非mProcedureStack是参考。

于 2012-09-26T03:16:44.177 回答
1

此问题的最常见原因是当您返回一个悬空引用时,例如:

int& foo() {
   int bar = 5;
   return bar;
}

现在返回的引用foo指向堆栈并将包含未定义的数据。

于 2012-09-26T03:16:55.703 回答