Skip to content

tcp客户端主动断开连接closesocket时程序崩溃 #367

@LinHaoo

Description

@LinHaoo

进行压测,创建大量tcp客户端,连接到远程tcp服务端后,又主动断开链接(也有可能tcp服务端先断开),程序出现崩溃
以下时core文件的打印:
Program terminated with signal 11, Segmentation fault.
#0 __GI___libc_free (mem=0x2020202020202020) at malloc.c:2941
2941 if (chunk_is_mmapped(p)) /* release mmapped memory. /
(gdb)
(gdb)
(gdb) bt
#0 __GI___libc_free (mem=0x2020202020202020) at malloc.c:2941
#1 0x0000000000534f4c in hv_free (ptr=0x2020202020202020) at /root/github/libhv/base/hbase.c:71
#2 0x0000000000429b61 in hv::TcpClientEventLoopTmplhv::SocketChannel::setReconnect (this=0x7f662c0bf790, setting=0x0)
at /root/sources/rtpswitch/third/libhv/include/hv/TcpClient.h:212
#3 0x000000000042686f in hv::TcpClientEventLoopTmplhv::SocketChannel::closesocket()::{lambda()#1}::operator()() const (
__closure=0x7f662c0a6720) at /root/sources/rtpswitch/third/libhv/include/hv/TcpClient.h:92
#4 0x000000000043ea3a in std::__invoke_impl<void, hv::TcpClientEventLoopTmplhv::SocketChannel::closesocket()::{lambda()#1}&>(std::__invoke_other, hv::TcpClientEventLoopTmplhv::SocketChannel::closesocket()::{lambda()#1}&) (__f=...)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/invoke.h:61
#5 0x0000000000436d9b in std::__invoke_r<void, hv::TcpClientEventLoopTmplhv::SocketChannel::closesocket()::{lambda()#1}&>(void&&, (hv::TcpClientEventLoopTmplhv::SocketChannel::closesocket()::{lambda()#1}&)...) (__fn=...)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/invoke.h:111
#6 0x000000000042ec6f in std::_Function_handler<void (), hv::TcpClientEventLoopTmplhv::SocketChannel::closesocket()::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...) at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_function.h:290
#7 0x0000000000425b90 in std::function<void ()>::operator()() const (this=0x7f662c0a6720)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_function.h:590
#8 0x000000000042385a in hv::EventLoop::queueInLoop(std::function<void ()>)::{lambda(hv::Event
)#1}::operator()(hv::Event*) const
(__closure=0x7f662c0a6720, ev=0x7f662c00f740) at /root/sources/rtpswitch/third/libhv/include/hv/EventLoop.h:172
#9 0x000000000043681c in std::__invoke_impl<void, hv::EventLoop::queueInLoop(std::function<void ()>)::{lambda(hv::Event*)#1}&, hv::Event*>(std::__invoke_other, hv::EventLoop::queueInLoop(std::function<void ()>)::{lambda(hv::Event*)#1}&, hv::Event*&&) (__f=...)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/invoke.h:61
#10 0x000000000042e4d1 in std::__invoke_r<void, hv::EventLoop::queueInLoop(std::function<void ()>)::{lambda(hv::Event*)#1}&, hv::Event*>(void&&, (hv::EventLoop::queueInLoop(std::function<void ()>)::{lambda(hv::Event*)#1}&)...) (__fn=...)
---Type to continue, or q to quit---
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/invoke.h:111
#11 0x00000000004296ef in std::_Function_handler<void (hv::Event*), hv::EventLoop::queueInLoop(std::function<void ()>)::{lambda(hv::Event*)#1}>::_M_invoke(std::_Any_data const&, hv::Event*&&) (__functor=...,
__args#0=<unknown type in /home/ivms/rtpswitch/rtpswitch, CU 0x4fcd5, DIE 0xe48e3>)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_function.h:290
#12 0x000000000042661b in std::function<void (hv::Event*)>::operator()(hv::Event*) const (this=0x7f662c00f780,
__args#0=0x7f662c00f740) at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_function.h:590
#13 0x0000000000423bb8 in hv::EventLoop::onCustomEvent (hev=0x7f66595a8a70)
at /root/sources/rtpswitch/third/libhv/include/hv/EventLoop.h:224
#14 0x000000000053c4c7 in eventfd_read_cb (io=0x7f6650000b80, buf=0x12c4b90, readbytes=8) at /root/github/libhv/event/hloop.c:223
#15 0x00000000005394e6 in hio_read_cb (io=0x7f6650000b80, buf=0x12c4b90, len=8) at /root/github/libhv/event/hevent.c:405
#16 0x0000000000539389 in hio_handle_read (io=0x7f6650000b80, buf=0x12c4b90, readbytes=8) at /root/github/libhv/event/hevent.c:372
#17 0x000000000053ec1b in __read_cb (io=0x7f6650000b80, buf=0x12c4b90, readbytes=8) at /root/github/libhv/event/nio.c:48
#18 0x000000000053f76e in nio_read (io=0x7f6650000b80) at /root/github/libhv/event/nio.c:332
#19 0x000000000053fa28 in hio_handle_events (io=0x7f6650000b80) at /root/github/libhv/event/nio.c:410
#20 0x000000000053c002 in hloop_process_pendings (loop=0x12c29f0) at /root/github/libhv/event/hloop.c:122
#21 0x000000000053c29f in hloop_process_events (loop=0x12c29f0, timeout_ms=100) at /root/github/libhv/event/hloop.c:185
#22 0x000000000053cd66 in hloop_run (loop=0x12c29f0) at /root/github/libhv/event/hloop.c:458
#23 0x000000000045b345 in hv::EventLoop::run (this=0x12c2710) at /root/sources/rtpswitch/third/libhv/include/hv/EventLoop.h:54
#24 0x000000000045bf44 in hv::EventLoopThread::loop_thread(std::function<int ()> const&, std::function<int ()> const&) (
this=0x12c26d0, pre=..., post=...) at /root/sources/rtpswitch/third/libhv/include/hv/EventLoopThread.h:97
#25 0x0000000000482b3f in std::__invoke_impl<void, void (hv::EventLoopThread::)(std::function<int ()> const&, std::function<int ()> const&), hv::EventLoopThread, std::function<int ()>, std::function<int ()> >(std::__invoke_memfun_deref, void (hv::EventLoopThread---Type to continue, or q to quit---
::&&)(std::function<int ()> const&, std::function<int ()> const&), hv::EventLoopThread&&, std::function<int ()>&&, std::function<int ()>&&) (__f=<unknown type in /home/ivms/rtpswitch/rtpswitch, CU 0x11b1e9, DIE 0x19695b>,
__t=<unknown type in /home/ivms/rtpswitch/rtpswitch, CU 0x11b1e9, DIE 0x19696a>)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/invoke.h:74
#26 0x00000000004829eb in std::__invoke<void (hv::EventLoopThread::)(std::function<int ()> const&, std::function<int ()> const&), hv::EventLoopThread, std::function<int ()>, std::function<int ()> >(void (hv::EventLoopThread::&&)(std::function<int ()> const&, std::function<int ()> const&), hv::EventLoopThread&&, std::function<int ()>&&, std::function<int ()>&&) (
__fn=<unknown type in /home/ivms/rtpswitch/rtpswitch, CU 0x11b1e9, DIE 0x196bd8>)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/invoke.h:96
#27 0x000000000048288f in std::thread::_Invoker<std::tuple<void (hv::EventLoopThread::)(std::function<int ()> const&, std::function<int ()> const&), hv::EventLoopThread, std::function<int ()>, std::function<int ()> > >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) (this=0x12c7368) at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_thread.h:253
#28 0x0000000000482678 in std::thread::_Invoker<std::tuple<void (hv::EventLoopThread::)(std::function<int ()> const&, std::function<int ()> const&), hv::EventLoopThread, std::function<int ()>, std::function<int ()> > >::operator()() (this=0x12c7368)
at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_thread.h:260
#29 0x00000000004823f8 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (hv::EventLoopThread::)(std::function<int()> const&, std::function<int ()> const&), hv::EventLoopThread, std::function<int ()>, std::function<int ()> > > >::_M_run() (
this=0x12c7360) at /opt/rh/devtoolset-11/root/usr/include/c++/11/bits/std_thread.h:211
#30 0x00000000005fb954 in execute_native_thread_routine ()
#31 0x00007f665b483dd5 in start_thread (arg=0x7f66595a9700) at pthread_create.c:307
#32 0x00007f665aeaaead in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions