Summary: | ASTERISK-12605: [patch] chan_sip is leaking in build_peer | ||
Reporter: | Sergey Tamkovich (sergee) | Labels: | |
Date Opened: | 2008-08-18 03:26:45 | Date Closed: | 2008-10-23 11:01:22 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_sip/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) allocs.txt.bz2 ( 1) chan_sip-3leaks-16-r151244.diff ( 2) chan_sip-leak-trunk-r151414.diff ( 3) summary.txt | |
Description: | I'm using RealTime setup with 1.6.0 branch. Asterisk runs out of memory in a 2 days. ****** ADDITIONAL INFORMATION ****** memory show allocations: .... 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 2056 bytes allocated in build_peer at line 20286 of chan_sip.c 17 bytes allocated in __ast_cli_register at line 1451 of cli.c 12 bytes allocated in ind_load_module at line 343 of res_indications.c 12 bytes allocated in ind_load_module at line 343 of res_indications.c 5 bytes allocated in ind_load_module at line 348 of res_indications.c -2113019330 bytes allocated (9352 in caches) in 1071787 allocations sip*CLI> memory show summary 516 bytes in 1 allocations in file 'enum.c' 752 bytes in 2 allocations in file 'res_crypto.c' 12 bytes in 1 allocations in file 'pbx_config.c' 12316 bytes in 1 allocations in file 'stdtime/localtime.c' 19 bytes in 1 allocations in file 'btree/bt_utils.c' 1 bytes in 1 allocations in file 'app_stack.c' 785 bytes in 2 allocations in file 'el.c' 36 bytes in 1 allocations in file 'sig.c' 576 bytes in 4 allocations in file 'logger.c' 1024 bytes in 1 allocations in file 'hist.c' 1024 bytes in 1 allocations in file 'search.c' 14 bytes in 2 allocations in file 'http.c' 3380 bytes in 5 allocations in file 'app_voicemail.c' 880 bytes in 5 allocations in file 'res_musiconhold.c' 101 bytes in 4 allocations in file 'event.c' 96 bytes in 2 allocations in file 'devicestate.c' 2420 bytes in 51 allocations in file 'hashtab.c' 8634 bytes in 57 allocations in file 'term.c' 4536 bytes in 21 allocations in file 'file.c' 454328 bytes in 33 allocations in file 'translate.c' 540208 bytes ( 6664 cache) in 85 allocations in file 'frame.c' 1984 bytes in 4 allocations in file 'map.c' 21684 bytes in 6 allocations in file 'mpool/mpool.c' 584 bytes in 2 allocations in file 'btree/bt_open.c' 2903552 bytes in 53 allocations in file 'udptl.c' 5207 bytes in 70 allocations in file 'app_queue.c' 28984 bytes in 163 allocations in file 'astobj2.c' 5148 bytes in 4 allocations in file 'io.c' 2044 bytes in 52 allocations in file 'key.c' 601128 bytes in 108 allocations in file 'rtp.c' 21908 bytes in 112 allocations in file '/usr/src/asterisk-1.6.0/include/asterisk/threadstorage.h' 7252 bytes in 202 allocations in file 'pbx.c' 3112 bytes in 4 allocations in file 'chared.c' 6428 bytes in 343 allocations in file 'cli.c' 8415 bytes in 147 allocations in file 'loader.c' 2406 bytes in 79 allocations in file 'app_dial.c' 2858 bytes in 202 allocations in file 'history.c' 1472 bytes in 62 allocations in file 'manager.c' 17081 bytes in 374 allocations in file '/usr/src/asterisk-1.6.0/include/asterisk/strings.h' 102170 bytes in 238 allocations in file 'utils.c' 20859 bytes in 1192 allocations in file 'res_indications.c' 5904 bytes in 218 allocations in file 'asterisk.c' 9572 bytes in 266 allocations in file 'sched.c' 380070 bytes in 6691 allocations in file 'config.c' 6226052 bytes in 5541 allocations in file 'cdr.c' 12547 bytes in 251 allocations in file 'chanvars.c' 52263 bytes in 200 allocations in file 'channel.c' -2089347110 bytes in 1074990 allocations in file 'chan_sip.c' -2077864768 bytes allocated (6664 in caches) in 1091855 allocations | ||
Comments: | By: Sergey Tamkovich (sergee) 2008-08-18 03:44:42 summary.txt => memory show summary allocs.txt.bz2 => memory show allocations By: Russell Bryant (russell) 2008-09-15 23:43:54 Can you please also include which realtime related sip.conf options you are using? By: Sergey Tamkovich (sergee) 2008-10-21 05:54:38 Sorry for being unresponsive, here is my sip.conf [general] context=default allowguest=no match_auth_username=yes allowoverlap=no allowtransfer=no srvlookup=no relaxdtmf=yes sendrpid = yes videosupport=yes maxcallbitrate=2048 rtptimeout=60 rtpholdtimeout=300 allowsubscribe=yes notifyringing = yes notifyhold = yes callcounter = yes t38pt_udptl = yes canreinvite=yes directrtpsetup=no rtsavesysname=yes rtupdate=yes By: Sergey Tamkovich (sergee) 2008-10-23 04:38:02 Actualy there were 3 leaks The major leak was introduced in revision 123547 http://svn.digium.com/view/asterisk?view=rev&revision=123547 ast_free(peer); was removed from static void sip_destroy_peer(struct sip_peer *peer) Two minor leaks were in st_get_mode() and st_get_se() somebody forgot to call unref_peer() and unref_user() - this 2 leaks aren't present in trunk. Patches for 1.6.0 and trunk are available. By: Russell Bryant (russell) 2008-10-23 07:03:49 The trunk patch isn't quite right. When this object was converted to astobj2, removing the ast_free() from there was the right thing to do. In astobj2, the object itself gets free'd for you. The destructor only cleans up internal allocations. With astobj (which is what is used in 1.6.0), the destructor has to free the object itself, as well. I'll work on integrating your 1.6.0 patch today. Thanks! By: Digium Subversion (svnbot) 2008-10-23 11:01:20 Repository: asterisk Revision: 151765 U branches/1.6.0/channels/chan_sip.c ------------------------------------------------------------------------ r151765 | russell | 2008-10-23 11:01:19 -0500 (Thu, 23 Oct 2008) | 12 lines Fix some memory leaks. These issues are 1.6.0 specific. - Freeing the peer got accidentally removed from the peer's destructor. It is still needed for astobj, but not for astobj2. - Fix some places that called find_user or find_peer, but did not release the reference that was returned. (closes issue ASTERISK-12605) Reported by: sergee Patches: chan_sip-3leaks-16-r151244.diff uploaded by sergee (license 138) Tested by: sergee ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=151765 |