定位问题3:明明堆栈已经打印出来了,偏就是定位不出来?

堆栈如下,明明是在AAA::B函数里core了,而且是概率core的,可就是定位不出来

B函数很简单

1. 第一句打印入参

2. 其它都是函数调用

3. 打印退出消息

对于1 ,参数如下,不可能为nullptr,也排查了调用处(仅2处),不存在问题

const string& state, const string& reason, const string& screen, const string& reason_phase

对于2,如果是其它调用的问题,堆栈应该更深才对

对于3. 比1打印的还少,而且没参数,更不会有问题

尝试将1中的入参进一步做了校验,问题仍存在

 

后在与同事讨论中发现,呃,问题太明显了,如下

DDD* pDesktop = getDesktop(msg->msg_sender_);
        if (pDesktop == nullptr){
            VX_WARN("get desktop nullptr %s",msg->msg_sender_.c_str());  --------------------------------这一句有打印
        }
        pDesktop->B(state, reason, screen, reason_phase);
        这不就说明此时,pDesktop是nullptr吗?--------------肯定是指针悬空了啊
 
总结:
  1. 对于堆栈的理解还是有偏差
  2. 对于难于定位的问题,不妨将范围稍放大一点看一下
 

Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000004f72cc in AAA::B(std::string const&, std::string const&, std::string const&, std::string const&) ()
[Current thread is 1 (Thread 0x7fbc1e3010 (LWP 562))]
(gdb) bt
#0 0x00000000004f72cc in AAA::A(std::string const&, std::string const&, std::string const&, std::string const&) ()
#1 0x00000000004dd450 in BBB::processRemoteMsg(RecvMessage*) ()
#2 0x00000000004e0048 in ScrollWidget::onRecvMsg(RecvMessage*) ()

posted @ 2025-10-21 19:33  知易  阅读(1)  评论(0)    收藏  举报