Metaswitch/sprout — pull request #163 by telecore-ivan (2013-07-22 14:26:42+00:00)
Title: De-registration of not registered client results in segmentation fault in bono

The crash could be reproduced on a running system by restarting the bono node and after that stop the SIP client to initiate de-registration.

I've implemented a very basic unit test to reproduce the crash and a simple fix.

I was not able to find in RFCs and 3GPP docs what should be the response in this case so the proposed fix just prevent the segmentation fault and doesn't change the behavior.

[ RUN ] StatefulEdgeProxyTest.TestEdgeDeregister
*** handling signal 11 ***
[Thread debugging using libthread_db enabled]

Thread 1 (Thread 0x2b48f3df25c0 (LWP 8769)):
#0 0x00002b48f1bf748d in __libc_waitpid (pid=, stat_loc=, options=) at ../sysdeps/unix/sysv/linux/waitpid.c:41
#1 0x00002b48f1b7d29e in do_system (line=0x19d6418 "/usr/bin/gdb -nx --batch /proc/8769/exe 8769 -ex 'thread apply all bt'") at ../sysdeps/posix/system.c:149
#2 0x00002b48f1b7d6b0 in __libc_system (line=) at ../sysdeps/posix/system.c:190
#3 0x000000000058b417 in test_main_handle_signal (xiSigNum=11) at ut/test_main.cpp:117
#4
#5 Flow::set_identity (this=0x19ba850, uri=0x41853d0, is_default=true, expires=1374498256) at flowtable.cpp:383
#6 0x000000000043447a in proxy_process_register_response (rdata=0x4182bb8) at stateful_proxy.cpp:1567
#7 0x00000000004370a8 in UASTransaction::on_new_client_response (this=0x198ee30, uac_data=0x19a2bc0, rdata=0x4182bb8) at stateful_proxy.cpp:2053
#8 0x000000000043cc04 in UACTransaction::on_tsx_state (this=0x19a2bc0, event=0x7fffb231bf30) at stateful_proxy.cpp:3088
#9 0x000000000042cccd in tu_on_tsx_state (tsx=0x198d658, event=0x7fffb231bf30) at stateful_proxy.cpp:353
#10 0x00000000007a906e in tsx_set_state (tsx=0x198d658, state=PJSIP_TSX_STATE_COMPLETED, event_src_type=PJSIP_EVENT_RX_MSG, event_src=0x4182bb8) at ../src/pjsip/sip_transaction.c:1199
#11 0x00000000007ac4f0 in tsx_on_state_proceeding_uac (tsx=0x198d658, event=0x7fffb231c020) at ../src/pjsip/sip_transaction.c:2903
#12 0x00000000007ab99c in tsx_on_state_calling (tsx=0x198d658, event=0x7fffb231c020) at ../src/pjsip/sip_transaction.c:2486
#13 0x00000000007aa166 in pjsip_tsx_recv_msg (tsx=0x198d658, rdata=0x4182bb8) at ../src/pjsip/sip_transaction.c:1754
#14 0x00000000007a85f6 in mod_tsx_layer_on_rx_response (rdata=0x4182bb8) at ../src/pjsip/sip_transaction.c:863
#15 0x0000000000795eca in pjsip_endpt_process_rx_data (endpt=0x1ab9408, rdata=0x4182bb8, p=0x7fffb231c170, p_handled=0x7fffb231c1ac) at ../src/pjsip/sip_endpoint.c:893
#16 0x00000000007961a3 in endpt_on_rx_msg (endpt=0x1ab9408, status=0, rdata=0x4182bb8) at ../src/pjsip/sip_endpoint.c:1032
#17 0x000000000079f498 in pjsip_tpmgr_receive_packet (mgr=0x3ac2c40, rdata=0x4182bb8) at ../src/pjsip/sip_transport.c:1731
#18 0x00000000005a24dc in SipTest::inject_msg (this=0x1ab9040, msg="SIP/2.0 200 OK\r\nVia: SIP/2.0/TCP 127.0.0.1:5058;rport=5058;received=10.6.6.8;branch=z9hG4bKPjv21MpJ.NarmLH8jBuuYz24kFWLeNqKYs\r\nVia: SIP/2.0/TCP 1.2.3.4:49152;rport=49152;received=1.2.3.4;branch=z9hG4b"..., tp=0x19e97f0) at ut/siptest.cpp:311
#19 0x000000000065ec2c in StatefulEdgeProxyTest::doRegisterEdge (this=0x1ab9040, xiTp=0x1ab4de0, xoToken="sip:JuQNWo6s6m@testnode:5058;transport=TCP;lr", xoBareToken="JuQNWo6s6m@testnode", expires=0, integrity="no", extraRspHeaders="", firstHop=false, supported="outbound, path", expectPath=true, via="") at ut/stateful_proxy_test.cpp:1448
#20 0x0000000000674967 in StatefulEdgeProxyTest_TestEdgeDeregister_Test::TestBody (this=0x1ab9040) at ut/stateful_proxy_test.cpp:1902