{"action":"created","issue":{"url":"https://api.github.com/repos/OpenSIPS/opensips/issues/1312","repository_url":"https://api.github.com/repos/OpenSIPS/opensips","labels_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/1312/labels{/name}","comments_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/1312/comments","events_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/1312/events","html_url":"https://github.com/OpenSIPS/opensips/issues/1312","id":305553944,"number":1312,"title":"Segfaults in TM module, latest git from 2.3 branch","user":{"login":"sisoftrg","id":492146,"avatar_url":"https://avatars1.githubusercontent.com/u/492146?v=4","gravatar_id":"","url":"https://api.github.com/users/sisoftrg","html_url":"https://github.com/sisoftrg","followers_url":"https://api.github.com/users/sisoftrg/followers","following_url":"https://api.github.com/users/sisoftrg/following{/other_user}","gists_url":"https://api.github.com/users/sisoftrg/gists{/gist_id}","starred_url":"https://api.github.com/users/sisoftrg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sisoftrg/subscriptions","organizations_url":"https://api.github.com/users/sisoftrg/orgs","repos_url":"https://api.github.com/users/sisoftrg/repos","events_url":"https://api.github.com/users/sisoftrg/events{/privacy}","received_events_url":"https://api.github.com/users/sisoftrg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-15T13:32:50Z","updated_at":"2018-03-15T13:47:49Z","closed_at":null,"author_association":"NONE","body":"Under some amount of load, opensips 2.3 (2.3.3 and current git) segfaults like this, many times in a day on two different configurations:\r\n```\r\n[1148953.892148] opensips[13019]: segfault at 7f4a5564785c ip 00007f3777dacae3 sp 00007ffdf1aefc30 error 6 in tm.so[7f3777d8e000+61000]\r\n[1171310.194968] opensips[13109]: segfault at 7f574c660a9c ip 00007f4e363aeae3 sp 00007ffe29019010 error 6 in tm.so[7f4e36390000+61000]\r\n```\r\n\r\nbacktrace:\r\n```\r\nCore was generated by `/usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg'.\r\nProgram terminated with signal SIGSEGV, Segmentation fault.\r\n#0  0x00007f0e97a21837 in tsl (lock=0x7f2bf7ee8718) at ../../mem/../fastlock.h:105\r\n105             asm volatile(\r\n(gdb) thread apply all bt\r\n\r\nThread 1 (Thread 0x7f109aebd700 (LWP 19225)):\r\n#0  0x00007f0e97a21837 in tsl (lock=0x7f2bf7ee8718) at ../../mem/../fastlock.h:105\r\n#1  0x00007f0e97a21886 in get_lock (lock_struct=0x7f2bf7ee8718, file=0x7f0e97a8d6e4 \"lock.h\", func=0x7f0e97a8debe <__FUNCTION__.9169> \"_lock\", line=100) at ../../mem/../fastlock.h:217\r\n#2  0x00007f0e97a21eb0 in _lock (s=0x7f2bf7ee8718, file=0x7f0e97a8d824 \"h_table.c\", function=0x7f0e97a8deb4 <__FUNCTION__.10009> \"lock_hash\", line=88) at lock.h:100\r\n#3  0x00007f0e97a223cf in lock_hash (i=1752196460) at h_table.c:88\r\n#4  0x00007f0e97a3c97e in t_unref_cell (c=0x7f0ea1f04c28) at t_lookup.c:1166\r\n#5  0x00007f0e97a4ead3 in do_t_cleanup (foo=0x7f0e97ca7080 <faked_req>, bar=0x0) at tm.c:749\r\n#6  0x0000000000427b09 in exec_post_cb (msg=0x7f0e97ca7080 <faked_req>, cb=0x7f1098558058) at script_cb.c:180\r\n#7  0x0000000000427b8d in exec_post_req_cb (msg=0x7f0e97ca7080 <faked_req>) at script_cb.c:198\r\n#8  0x00007f0e97a468bd in run_resume_route (resume_route=5, msg=0x7f0e97ca7080 <faked_req>) at async.c:65\r\n#9  0x00007f0e97a48524 in t_handle_async (msg=0x7f0e97ca7080 <faked_req>, a=0x7f1098545478, resume_route=5) at async.c:351\r\n#10 0x0000000000445e92 in do_action (a=0x7f1098545690, msg=0x7f0e97ca7080 <faked_req>) at action.c:1883\r\n#11 0x000000000043df5f in run_action_list (a=0x7f1098544ec0, msg=0x7f0e97ca7080 <faked_req>) at action.c:172\r\n#12 0x000000000043de2c in run_actions (a=0x7f1098544ec0, msg=0x7f0e97ca7080 <faked_req>) at action.c:137\r\n#13 0x0000000000440b18 in do_action (a=0x7f1098544a90, msg=0x7f0e97ca7080 <faked_req>) at action.c:761\r\n#14 0x000000000043df5f in run_action_list (a=0x7f1098544a90, msg=0x7f0e97ca7080 <faked_req>) at action.c:172\r\n#15 0x000000000044240b in do_action (a=0x7f1098544bc0, msg=0x7f0e97ca7080 <faked_req>) at action.c:1124\r\n#16 0x000000000043df5f in run_action_list (a=0x7f109853f850, msg=0x7f0e97ca7080 <faked_req>) at action.c:172\r\n#17 0x000000000043de2c in run_actions (a=0x7f109853f850, msg=0x7f0e97ca7080 <faked_req>) at action.c:137\r\n#18 0x000000000043e0e6 in run_top_route (a=0x7f109853f850, msg=0x7f0e97ca7080 <faked_req>) at action.c:214\r\n#19 0x00007f0e97a059ac in run_failure_handlers (t=0x7f0ea2152748) at t_reply.c:594\r\n#20 0x00007f0e97a06b77 in t_should_relay_response (Trans=0x7f0ea2152748, new_code=486, branch=0, should_store=0x7ffd5f113ab0, should_relay=0x7ffd5f113ab4, cancel_bitmap=0x7ffd5f113b5c, reply=0x7f1098709458)\r\n    at t_reply.c:924\r\n#21 0x00007f0e97a074c4 in relay_reply (t=0x7f0ea2152748, p_msg=0x7f1098709458, branch=0, msg_status=486, cancel_bitmap=0x7ffd5f113b5c) at t_reply.c:1146\r\n#22 0x00007f0e97a0fdbd in reply_received (p_msg=0x7f1098709458) at t_reply.c:1535\r\n#23 0x0000000000457871 in forward_reply (msg=0x7f1098709458) at forward.c:495\r\n#24 0x000000000042d478 in receive_msg (\r\n    buf=0x860040 <buf> \"SIP/2.0 486 Busy Here\\r\\nVia: SIP/2.0/UDP URI;branch=z9hG4bK2ea9.f3269ea3.0\\r\\nFrom: <sip:URI>;tag=1112478485-3893447976-2319763389-1937474651\\r\\nTo: <URI\"..., len=527, rcv_info=0x7ffd5f113d30, existing_context=0x0) at receive.c:257\r\n#25 0x000000000057e36a in udp_read_req (si=0x7f1098559620, bytes_read=0x7ffd5f113df8) at net/proto_udp/proto_udp.c:192\r\n#26 0x000000000055d53b in handle_io (fm=0x7f109856b8f8, idx=0, event_type=1) at net/net_udp.c:259\r\n#27 0x000000000055c41b in io_wait_loop_epoll (h=0x880b00 <_worker_io>, t=1, repeat=0) at net/../io_wait_loop.h:280\r\n#28 0x000000000055deb9 in udp_start_processes (chd_rank=0x84c828 <chd_rank>, startup_done=0x7f0e989e1af8) at net/net_udp.c:389\r\n#29 0x00000000004c21f3 in main_loop () at main.c:677\r\n#30 0x00000000004c52e5 in main (argc=11, argv=0x7ffd5f114138) at main.c:1283\r\n\r\n(gdb) l\r\n100                     \" adcl $0, %0 \\n\\t\"\r\n101                     : \"=q\" (val), \"=m\" (*lock) : \"0\"(val) : \"memory\", \"cc\" /* \"cc\" */\r\n102             );\r\n103     #else\r\n104             val=1;\r\n105             asm volatile(\r\n106                     \" xchg %1, %0\" : \"=q\" (val), \"=m\" (*lock) : \"0\" (val) : \"memory\"\r\n107             );\r\n108     #endif /*NOSMP*/\r\n109     #elif defined(__CPU_sparc64) || defined(__CPU_sparc)\r\n(gdb) p val\r\n$1 = 1\r\n(gdb) p lock\r\n$2 = (volatile int *) 0x7f2bf7ee8718\r\n(gdb) p *lock\r\nCannot access memory at address 0x7f2bf7ee8718\r\n```\r\n\r\nWalking by trace:\r\n```\r\n(gdb) l\r\n86      void lock_hash(int i)\r\n87      {\r\n88              lock(&tm_table->entrys[i].mutex);\r\n89      }\r\n(gdb) p i\r\n$5 = 1752196460\r\n(gdb) p tm_table->entrys[i]\r\nCannot access memory at address 0x7f2bf7ee8700\r\n(gdb) p sizeof(tm_table->entrys)\r\n$7 = 4718592\r\n(gdb) up\r\n#4  0x00007f0e97a3c97e in t_unref_cell (c=0x7f0ea1f04c28) at t_lookup.c:1166\r\n1166            UNREF(c);\r\n(gdb) up\r\n#5  0x00007f0e97a4ead3 in do_t_cleanup (foo=0x7f0e97ca7080 <faked_req>, bar=0x0) at tm.c:749\r\n749                     t_unref_cell(t);\r\n(gdb) p t->hash_index\r\n$15 = 1752196460\r\n```\r\nIndex looks definitely big, pointing out of allocated memory.\r\n"},"comment":{"url":"https://api.github.com/repos/OpenSIPS/opensips/issues/comments/373381166","html_url":"https://github.com/OpenSIPS/opensips/issues/1312#issuecomment-373381166","issue_url":"https://api.github.com/repos/OpenSIPS/opensips/issues/1312","id":373381166,"user":{"login":"razvancrainea","id":1511224,"avatar_url":"https://avatars0.githubusercontent.com/u/1511224?v=4","gravatar_id":"","url":"https://api.github.com/users/razvancrainea","html_url":"https://github.com/razvancrainea","followers_url":"https://api.github.com/users/razvancrainea/followers","following_url":"https://api.github.com/users/razvancrainea/following{/other_user}","gists_url":"https://api.github.com/users/razvancrainea/gists{/gist_id}","starred_url":"https://api.github.com/users/razvancrainea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/razvancrainea/subscriptions","organizations_url":"https://api.github.com/users/razvancrainea/orgs","repos_url":"https://api.github.com/users/razvancrainea/repos","events_url":"https://api.github.com/users/razvancrainea/events{/privacy}","received_events_url":"https://api.github.com/users/razvancrainea/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T13:47:49Z","updated_at":"2018-03-15T13:47:49Z","author_association":"OWNER","body":"Can you print `*t` and see if there are fields ok, or everything is messed up?"}}
{"actor":{"display_login":"razvancrainea"}}