MonaSolutions / librtmfp

LGPL implementation of RTMFP (client part)
GNU Lesser General Public License v3.0
77 stars 26 forks source link

Segmentation fault #1

Closed lxlenovostar closed 7 years ago

lxlenovostar commented 7 years ago

I'm stressing the rtmfp server by librtmfp. the main codes is:

int main(int argc,char * argv[]){   
    int flag = 1;

    snprintf(url, sizeof(url), "%s", url_flv + 6); // url_flv is a address of a rtmfp server. 

    RTMFP_Init(&config, &groupConfig, 1); 
    config.pOnSocketError = onSocketError;
    config.pOnStatusEvent = onStatusEvent;
    config.isBlocking = groupConfig.isBlocking = 1;
    RTMFP_InterruptSetCallback(IsInterrupted, NULL);    

    unsigned int context_keep = 0;
    unsigned int context = 0;
    context_keep = RTMFP_Connect(url, &config);    
    if (context_keep != 0) {
        try_again:
            context = RTMFP_Connect(url, &config);    
            if (context != 0) {
                RTMFP_Close(context);
                goto try_again;
            } else {
                RTMFP_Close(context_keep);
                RTMFP_Terminate(); 
                return -1; 
            }   
    }   
    RTMFP_Close(context_keep);

    RTMFP_Terminate(); // To ensure that invoker is dead
    printf("End of the Program!\n");

    return 0;

The running result is:

RTMFPSession.cpp[847] Peer ID : 
ff44c2d69a70c3f8a9740d418946bced3cbc320732744426663c99717aac3fa1
RTMFPSession.cpp[875] RTMFPSession is now connected to 123.103.16.146
Main.cpp[66] Status Event 'NetConnection.Connect.Success' : Connection succeeded
RTMFPSession.cpp[709] Sending peer info (port : 45426 - port ipv6 : 57390)
Invoker.cpp[93] Deleting connection 139...
Segmentation fault (core dumped)

I use gdb to debug it. ###################################################### gdb -c core.7015 ./TestClient ######################################################

Core was generated by `./TestClient'.
Program terminated with signal 11, Segmentation fault.
#0  0x00000039afb8fed8 in main_arena () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.132.el6_5.4.x86_64 keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-65.el6.x86_64 libcom_err-1.41.12-23.el6.x86_64 libgcc-4.4.7-18.el6.x86_64 libselinux-2.0.94-7.el6.x86_64 libstdc++-4.4.7-18.el6.x86_64 openssl-1.0.1e-57.el6.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) bt
#0  0x00000039afb8fed8 in main_arena () from /lib64/libc.so.6
#1  0x000000000044e982 in std::function<void ()()>::operator()() const ()
#2  0x000000000044e698 in Base::Event<void ()()>::operator=(Base::Event<void ()()> const&)::{lambda()#1}::operator()() const ()
#3  0x000000000044f0ed in _ZNSt17_Function_handlerIFvvEZN4Base5EventIS0_JEEaSERKS3_EUlvE_E9_M_invokeERKSt9_Any_data ()
#4  0x000000000044e982 in std::function<void ()()>::operator()() const ()
#5  0x000000000044e148 in _ZNK4Base5EventIFvvEJEEclEv ()
#6  0x00000000005270ab in Base::IOSocket::Send::Handle::handle(std::shared_ptr<Base::Socket> const&) ()
#7  0x0000000000526a69 in Base::IOSocket::Action::Handle::run(Base::Exception&) ()
#8  0x000000000044cfb3 in Base::Handler::flush(unsigned int) ()
#9  0x00000000004ad40f in Invoker::run(Base::Exception&, bool const volatile&) ()
#10 0x000000000046d5d4 in Base::Thread::process() ()
#11 0x0000000000471135 in _ZNKSt7_Mem_fnIMN4Base6ThreadEFvvEEclIJEvEEvPS1_DpOT_ ()
#12 0x0000000000471085 in _ZNSt12_Bind_simpleIFSt7_Mem_fnIMN4Base6ThreadEFvvEEPS2_EE9_M_invokeIJLm0EEEEvSt12_Index_tupleIJXspT_EEE ()
#13 0x0000000000470f83 in std::_Bind_simple<std::_Mem_fn<void (Base::Thread::*)()> ()(Base::Thread*)>::operator()() ()
#14 0x0000000000470f1c in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (Base::Thread::*)()> ()(Base::Thread*)> >::_M_run() ()
#15 0x0000003b16eb6470 in ?? () from /usr/lib64/libstdc++.so.6
#16 0x00000039afc079d1 in start_thread () from /lib64/libpthread.so.0
#17 0x00000039af8e886d in clone () from /lib64/libc.so.6
(gdb) 

Hope you can reply

thomasjammet commented 7 years ago

Hi,

Can you try with last version of librtmfp? Which version of MonaServer are you stressing? Can you send us your results? It could be interesting.

Thanks

lxlenovostar commented 7 years ago

Hi, I downloaded the latest version of the source code, but BUG still exists, the error information as follows:

RTMFPSession.cpp[758] Peer ID : 
d160dc2c7fa925d7713a5589d126e6738eeab79017eff1082a72e0a2e94447d4
RTMFPSession.cpp[786] RTMFPSession is now connected to 123.103.16.146
Main.cpp[70] Status Event 'NetConnection.Connect.Success' : Connection succeeded
RTMFPSession.cpp[620] Sending peer info (port : 36203 - port ipv6 : 55479)
Invoker.cpp[153] Deleting connection 50...
Invoker.cpp[241] Invoker, bad_function_call
Invoker.cpp[153] Deleting connection 1...
Invoker.cpp[153] Deleting connection 51...
Invoker.cpp[145] Connection at index 51 as already been removed
Invoker.cpp[145] Connection at index 1 as already been removed
Segmentation fault (core dumped)

I only use Static compilation, and use Main.cpp in "librtmfp-master/TestClient". I will send your Makefile and Main.cpp by Gmail. Thank you for your help.

lxlenovostar commented 7 years ago

Hi, The rtmfp server is: OpenRTMFP, not MonaServer.

lxlenovostar commented 7 years ago

Hi all. In the newest librtmfp, Segmentation fault is gone.