drogonframework / drogonframework/drogon

回调函数地址非法?

Open
#2,133 13 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

在容器运行环境有出现过几次trantor库的异常,从堆栈内存分析似乎是访问的回调函数地址为非法的,但更具体的无法确认。运行环境的网络请求很频繁且数据量很大。

```
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000056107971fed0 in ?? ()
[Current thread is 1 (Thread 0x7f552c07d700 (LWP 35934))]
(gdb) bt
#0 0x000056107971fed0 in ?? ()
#1 0x00007f552e60bbcc in trantor::Channel::handleEventSafely() () from /usr/local/lib/CET/libtrantor.so.1
#2 0x00007f552e60bc7f in trantor::Channel::handleEvent() () from /usr/local/lib/CET/libtrantor.so.1
#3 0x00007f552e600080 in trantor::EventLoop::loop() () from /usr/local/lib/CET/libtrantor.so.1
#4 0x00007f552e602342 in trantor::EventLoopThread::loopFuncs() () from /usr/local/lib/CET/libtrantor.so.1
#5 0x00007f55350e4b2f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007f5534cb0fa3 in start_thread (arg=) at pthread_create.c:486
#7 0x00007f5534dc2eff in __init_misc (argc=, argv=0x7f552c07d700, envp=0x561078c5c900) at init-misc.c:33
#8 0x0000000000000000 in ?? ()
```

下面是通过栈指针查到的信息,handleEventSafely偏移地址92我通过反汇编猜测大概是readCallback_?
```
(gdb) x /34a $rsp
0x7f552c07cd18: 0x7f552e60bbcc <_ZN7trantor7Channel17handleEventSafelyEv+92> 0x56107bcf3748
0x7f552c07cd28: 0x7f552e60bc7f <_ZN7trantor7Channel11handleEventEv+111> 0x7f552c07ce10
0x7f552c07cd38: 0x34e84ca07af18718 0x56107af18720
0x7f552c07cd48: 0x7f552c07ce10 0x7f552c07ce20
0x7f552c07cd58: 0x7f552e600080 <_ZN7trantor9EventLoop4loopEv+144> 0x561078a5f8d0
0x7f552c07cd68: 0x561078954208 0x561078a5f7e0
0x7f552c07cd78: 0x7f552c07cdf0 0x7f552c07ce10
0x7f552c07cd88: 0x7f552e602342 <_ZN7trantor15EventLoopThread9loopFuncsEv+626> 0x0
0x7f552c07cd98: 0x100000000000000 0x7f552c07ce10
0x7f552c07cda8: 0x561078a5f880 0x7f552c07cdd0
0x7f552c07cdb8: 0x7f552c07cd9f 0x7f552e93d510 <_ZNSt13__future_base13_State_baseV29_M_do_setEPSt8functionIFSt10unique_ptrINS_12_Result_baseENS3_8_DeleterEEvEEPb>
0x7f552c07cdc8: 0x0 0x561078a5f808
0x7f552c07cdd8: 0x7f552c07cda0 0x7f552e602c90 <_ZNSt14_Function_base13_Base_managerINSt13__future_base13_State_baseV27_SetterIPN7trantor9EventLoopEOS6_EEE10_M_managerERSt9_Any_dataRKSA_St18_Manager_operation>
0x7f552c07cde8: 0x7f552e602d20 <_ZNSt17_Function_handlerIFSt10unique_ptrINSt13__future_base12_Result_baseENS2_8_DeleterEEvENS1_13_State_baseV27_SetterIPN7trantor9EventLoopEOSA_EEE9_M_invokeERKSt9_Any_data> 0x0
0x7f552c07cdf8: 0x7f552c07cda8 0x7f552c07cdb0
0x7f552c07ce08: 0x7f552c07cdb8 0x1
0x7f552c07ce18: 0x7f552c07d700 0x0
```

下面是寄存器信息和栈帧信息
```
(gdb) i r
rax 0x56107971fed0 94628756979408
rbx 0x56107afbe990 94628782795152
rcx 0x56107a93d9b0 94628775975344
rdx 0x561078c5c900 94628745693440
rsi 0x56107a93d9b0 94628775975344
rdi 0x56107bcf3750 94628796643152
rbp 0x56107bcf3740 0x56107bcf3740
rsp 0x7f552c07cd18 0x7f552c07cd18
r8 0x56107ad76a40 94628780403264
r9 0x56107ad76a20 94628780403232
r10 0x7 7
r11 0x246 582
r12 0x7f552c07ce20 140003787656736
r13 0x7f552c07ce30 140003787656752
r14 0x1 1
r15 0x561078a5f8b0 94628743608496
rip 0x56107971fed0 0x56107971fed0
eflags 0x10246 [ PF ZF IF RF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
k0 0x0 0
k1 0x0 0
k2 0x0 0
k3 0x0 0
k4 0x0 0
k5 0x0 0
k6 0x0 0
k7 0x0 0
(gdb) i f
Stack level 0, frame at 0x7f552c07cd20:
rip = 0x56107971fed0; saved rip = 0x7f552e60bbcc
called by frame at 0x7f552c07cd30
Arglist at 0x7f552c07cd10, args:
Locals at 0x7f552c07cd10, Previous frame's sp is 0x7f552c07cd20
Saved registers:
rip at 0x7f552c07cd18
```

版本信息:
drogon 1.7.5
trantor 1.5.5

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.