<p></p>
<h3 dir="auto">Description</h3>
<p dir="auto">I made sipp 3000 calls test with tls connection in both caller side and callee side. After 3000calls are all established, the sipp will stay for 1min and then shut down all the network interfaces(iptables -I INPUT -j DROP) to let all tls connections timeout. And then repeat this test over and over again . But after some rounds of this kind of test, the calls can not reach 3000, only 2900calls will meet "out of mem" issue. The log is <g-emoji class="g-emoji" alias="+1" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png">👍</g-emoji> fm_malloc(): fm_malloc(0x7fd314a68000, 256760) called from core: tcp_main.c: tcpconn_new(1886), module: core; Free fragment not found!<br>
Our reliminary analysis: 1. this is not memory leak issue, 2. tls module malloc too many small fragments, which causes shared memory pool's utility reduced (we can see core.shmmem show us the free >= 200MB and fragments >=600000. But there is no consecutive free frags for a new tls connections)</p>
<h3 dir="auto">Reproduction</h3>
<h2 dir="auto">Settings:<br>
/opt/kamailio/sbin/kamailio -m 2048 -M 64<br>
----------------------cfg-------------------------<br>
enable_tls=yes<br>
tls_port_no=SIP_LISTEN_PORT_V6<br>
tls_max_connections=102400<br>
tcp_connection_lifetime=3605<br>
tcp_max_connections=102400<br>
dns_cache_min_ttl=1800<br>
open_files_limit=102400<br>
tcp_no_connect=no<br>
tcp_conn_wq_max=10240000<br>
tcp_async=no<br>
tcp_rd_buf_size=256000</h2>
<p dir="auto">Topology:<br>
sipp caller ------tls--------kamailio-----tls-------sipp callee (3000calls = 6000 tls connections)<br>
sipp and kamailio are running in the same PC</p>
<p dir="auto">Step1: start sipp 3000 call test<br>
Step2: after 3000 calls are all established, execute "iptables -I INPUT -j DROP"<br>
Step3: wait for all connections are timeout<br>
Step4: go to Step1: restart sipp scripts</p>
<h3 dir="auto">Expected Behavior</h3>
<p dir="auto">3000 calls test will always be successful</p>
<h4 dir="auto">Log Messages</h4>
<p dir="auto">------------------------------this is the log of "after 2900 calls"----------------------------<br>
Nov 16 05:36:27 kamailio[3103]: ERROR: [mem/f_malloc.c:416]: fm_search_defrag(): fm_search_defrag(0x7fd314a68000, 256760); Free fragment not found!<br>
Nov 16 05:36:27 kamailio[3103]: ERROR: [mem/f_malloc.c:499]: fm_malloc(): fm_malloc(0x7fd314a68000, 256760) called from core: tcp_main.c: tcpconn_new(1886), module: core; Free fragment not found!<br>
Nov 16 05:36:27 kamailio[3103]: ERROR: [tcp_main.c:1888]: tcpconn_new(): mem. allocation failure<br>
-----------------------------this is corex.shm_summary of "after 2900 calls"------------------------------<br>
corex [corex_rpc.c:176]: corex_rpc_shm_summary(): printing shared memory summary report<br>
fm_status: summarizing all alloc'ed. fragments:<br>
fm_status: count= 2928 size= 113296 bytes from tls: tls_ct_q.h: tls_ct_q_add(58)<br>
fm_status: count= 5857 size=1504098328 bytes from core: tcp_main.c: tcpconn_new(1886)<br>
fm_status: count= 1 size= 8192 bytes from core: counters.c: counters_prefork_init(207)<br>
fm_status: count= 22 size= 688 bytes from core: cfg_parser.c: cfg_parse_str(906)<br>
fm_status: count= 8 size= 1024 bytes from tls: tls_domain.c: fix_domain(1004)<br>
fm_status: count= 5856 size= 307200 bytes from tls: tls_server.c: tls_complete_init(228)<br>
fm_status: count= 1 size= 3072 bytes from sl: sl_stats.c: init_sl_stats_child(125)<br>
fm_status: count= 1 size= 768 bytes from kex: pkg_stats.c: pkg_proc_stats_init(79)<br>
fm_status: count= 5 size= 152 bytes from core: cfg/cfg_struct.c: cfg_clone_str(130)<br>
fm_status: count= 1 size= 712 bytes from core: cfg/cfg_struct.c: cfg_shmize(217)<br>
fm_status: count= 1 size= 2240 bytes from core: pt.c: init_pt(104)<br>
fm_status: count= 1 size= 8 bytes from core: pt.c: init_pt(110)<br>
fm_status: count= 1 size= 8 bytes from core: pt.c: init_pt(105)<br>
fm_status: count= 3 size= 120 bytes from gs: gs_mod.c: _append_to_blacklist_unsafe(692)<br>
fm_status: count= 3 size= 48 bytes from gs: gs_mod.c: _append_to_blacklist_unsafe(684)<br>
fm_status: count= 1008 size= 40320 bytes from gs: gs_mod.c: _append_to_backend_server_list_unsafe(472)<br>
fm_status: count= 1008 size= 16128 bytes from gs: gs_mod.c: _append_to_backend_server_list_unsafe(465)<br>
fm_status: count= 1011 size= 32352 bytes from gs: gs_mod.c: _update_one_slot_in_gs_hash_table_by_domain_dir(892)<br>
fm_status: count= 1011 size= 48528 bytes from gs: gs_mod.c: _update_one_slot_in_gs_hash_table_by_domain_dir(883)<br>
fm_status: count= 65536 size= 3670016 bytes from gs: gs_mod.c: mod_init(267)<br>
fm_status: count= 1 size= 1048576 bytes from gs: gs_mod.c: mod_init(260)<br>
fm_status: count= 1 size= 24 bytes from outbound: ob_mod.c: mod_init(104)<br>
fm_status: count= 1 size= 24 bytes from utils: conf.c: conf_init(549)<br>
fm_status: count= 1 size= 8 bytes from utils: utils.c: init_shmlock(160)<br>
fm_status: count= 8 size= 1536 bytes from tls: tls_domain.c: tls_new_domain(160)<br>
fm_status: count= 2 size= 96 bytes from tls: tls_domain.c: tls_new_cfg(1317)<br>
fm_status: count= 1 size= 8 bytes from tls: tls_ct_wrq.c: tls_ct_wq_init(49)<br>
fm_status: count= 1 size= 8 bytes from tls: tls_mod.c: mod_init(406)<br>
fm_status: count= 1 size= 8 bytes from tls: tls_mod.c: mod_init(390)<br>
fm_status: count= 1 size= 8 bytes from sl: sl_funcs.c: sl_startup(83)<br>
fm_status: count= 1 size= 8 bytes from sl: sl_stats.c: init_sl_stats(110)<br>
fm_status: count= 2 size= 64 bytes from core: cfg/cfg_ctx.c: cfg_register_ctx(47)<br>
fm_status: count= 63282 size= 2975704 bytes from tls: tls_init.c: ser_realloc(292)<br>
fm_status: count= 1 size= 8192 bytes from core: tcp_main.c: init_tcp(5649)<br>
fm_status: count= 1 size= 32768 bytes from core: tcp_main.c: init_tcp(5643)<br>
fm_status: count= 1 size= 8 bytes from core: tcp_main.c: init_tcp(5635)<br>
fm_status: count= 1 size= 8 bytes from core: tcp_main.c: init_tcp(5628)<br>
fm_status: count= 1 size= 8 bytes from core: tcp_main.c: init_tcp(5621)<br>
fm_status: count= 1 size= 8 bytes from core: tcp_main.c: init_tcp(5615)<br>
fm_status: count= 1 size= 8 bytes from core: tcp_main.c: init_tcp(5603)<br>
fm_status: count= 1 size= 8 bytes from core: usr_avp.c: init_avps(90)<br>
fm_status: count= 1 size= 8 bytes from core: usr_avp.c: init_avps(89)<br>
fm_status: count= 1 size= 16384 bytes from core: dst_blacklist.c: init_dst_blacklist(437)<br>
fm_status: count= 1 size= 8 bytes from core: dst_blacklist.c: init_dst_blacklist(430)<br>
fm_status: count= 2 size= 96 bytes from core: timer.c: timer_alloc(514)<br>
fm_status: count= 1 size= 8 bytes from core: dns_cache.c: init_dns_cache(369)<br>
fm_status: count= 1 size= 16384 bytes from core: dns_cache.c: init_dns_cache(361)<br>
fm_status: count= 1 size= 16 bytes from core: dns_cache.c: init_dns_cache(354)<br>
fm_status: count= 1 size= 8 bytes from core: dns_cache.c: init_dns_cache(345)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(283)<br>
fm_status: count= 1 size= 16384 bytes from core: timer.c: init_timer(282)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(281)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(280)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(269)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(237)<br>
fm_status: count= 1 size= 278544 bytes from core: timer.c: init_timer(220)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(219)<br>
fm_status: count= 1 size= 8 bytes from core: timer.c: init_timer(206)<br>
fm_status: count= 1 size= 64 bytes from core: cfg/cfg_struct.c: cfg_child_cb_new(830)<br>
fm_status: count= 1 size= 8 bytes from core: cfg/cfg_struct.c: sr_cfg_init(361)<br>
fm_status: count= 1 size= 8 bytes from core: cfg/cfg_struct.c: sr_cfg_init(354)<br>
fm_status: count= 1 size= 8 bytes from core: cfg/cfg_struct.c: sr_cfg_init(347)<br>
fm_status: count= 1 size= 8 bytes from core: cfg/cfg_struct.c: sr_cfg_init(335)<br>
fm_status: count= 1 size= 8 bytes from core: cfg/cfg_struct.c: sr_cfg_init(323)<br>
fm_status: count=502731 size= 292261096 bytes from tls: tls_init.c: ser_malloc(286)<br>
fm_status: count= 1 size= 24 bytes from tls: ../../lock_alloc.h: lock_set_alloc(70)<br>
fm_status: count= 1 size= 8 bytes from core: mem/shm.c: shm_core_lock_init(153)<br>
fm_status: -----------------------------</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/issues/2943">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZJEPUUPI6VCSYS3DW3UNHUBTANCNFSM5IQHXJTQ">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<img src="https://github.com/notifications/beacon/ABO7UZNSMVKXS3KLETXFTTDUNHUBTA5CNFSM5IQHXJT2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4PZK2S7Q.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/issues/2943",
"url": "https://github.com/kamailio/kamailio/issues/2943",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>