Roy Sigurd Karlsbakk
2003-Mar-02 08:24 UTC
[Asterisk-Users] Serious memory leak in asterisk (manager)
hi all after getting some (or - a lot) of messages from nagios, claiming asterisk to be down, I found this out... astping xxx times repeatedly, and the manager fails to start. this little script was used for testing. below, I've pasted the output from 'ps axfv' before and after the DoS, showing asterisk having allocated ~2GB RAM. roy #!/usr/bin/perl -w use strict; my $i = 0; while (1) { $i++; system("astping pbx"); if ($? != 0) { printf("asterisk crashed after %d astpings\n", $i); exit; } } ------ ps axfv before DoS 14917 ? S 0:00 60 254 2825 1544 0.6 SCREEN 14918 pts/3 S 0:00 302 505 2114 1008 0.3 \_ /bin/bash 15517 pts/3 S 0:02 8023 404 91615 4800 1.8 \_ asterisk -vvvcg 6062 pts/3 S 0:00 1 404 91615 4800 1.8 \_ asterisk -vv 6063 pts/3 S 0:00 1 404 91615 4800 1.8 \_ asterisk 6064 pts/3 S 0:00 1 404 91615 4800 1.8 \_ asterisk 6066 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6067 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6068 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6069 pts/3 S 0:00 1 404 91615 4800 1.8 \_ asterisk 6071 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6072 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6073 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6074 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk 6075 pts/3 S 0:00 0 404 91615 4800 1.8 \_ asterisk -------- ps axfv after DoS 14917 ? S 0:00 60 254 2825 1544 0.6 SCREEN 14918 pts/3 S 0:00 302 505 2114 1008 0.3 \_ /bin/bash 15517 pts/3 S 0:02 8023 404 2090463 7744 3.0 \_ asterisk -vvvc 6062 pts/3 S 0:00 4 404 2090463 7744 3.0 \_ asterisk - 6063 pts/3 S 0:00 1 404 2090463 7744 3.0 \_ asteri 6064 pts/3 S 0:00 1 404 2090463 7744 3.0 \_ asteri 6066 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6067 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6068 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6069 pts/3 S 0:00 1 404 2090463 7744 3.0 \_ asteri 6071 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6072 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6073 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6074 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri 6075 pts/3 S 0:00 0 404 2090463 7744 3.0 \_ asteri
Roy Sigurd Karlsbakk
2003-Mar-02 10:10 UTC
[Asterisk-Users] Serious memory leak in asterisk (manager)
hi running valgrind 1.9.4, I got this ... *CLI> stop now Beginning asterisk shutdown.... Asterisk cleanly ending (0). WARNING[2]: File asterisk.c, Line 183 (listener): Accept retured -1: Bad file descriptor ==24801===24801== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 613 from 4) ==24801===24801== 1 errors in context 1 of 3: ==24801== Conditional jump or move depends on uninitialised value(s) ==24801== at 0x41961A12: load_module (chan_capi.c:97) ==24801== by 0x8054117: ast_load_resource (loader.c:272) ==24801== by 0x8054372: load_modules (loader.c:318) ==24801== by 0x807BF04: main (asterisk.c:1290) ==24801===24801== 1 errors in context 2 of 3: ==24801== Conditional jump or move depends on uninitialised value(s) ==24801== at 0x41961890: load_module (chan_capi.c:97) ==24801== by 0x8054117: ast_load_resource (loader.c:272) ==24801== by 0x8054372: load_modules (loader.c:318) ==24801== by 0x807BF04: main (asterisk.c:1290) ==24801===24801== 1 errors in context 3 of 3: ==24801== Syscall param ioctl(generic) contains unaddressable byte(s) ==24801== at 0x420E12C4: __ioctl (in /lib/i686/libc-2.2.5.so) ==24801== by 0x419617D7: load_module (chan_capi.c:1844) ==24801== by 0x8054117: ast_load_resource (loader.c:272) ==24801== by 0x8054372: load_modules (loader.c:318) ==24801== Address 0x0 is not stack'd, malloc'd or free'd --24801-- --24801-- supp: 374 _dl_relocate_object*/dl_open_worker/_dl_catch_error*(Cond) --24801-- supp: 111 __pthread_mutex_unlock/_IO_funlockfile --24801-- supp: 106 pthread_error/__pthread_mutex_destroy/_IO_default_finish --24801-- supp: 22 pthread_error/__pthread_mutex_destroy/__closedir ==24801===24801== IN SUMMARY: 3 errors from 3 contexts (suppressed: 613 from 4) ==24801===24801== malloc/free: in use at exit: 334220 bytes in 2935 blocks. ==24801== malloc/free: 10547 allocs, 7612 frees, 1296366 bytes allocated. ==24801===24801== searching for pointers to 2935 not-freed blocks. ==24801== checked 9176212 bytes. ==24801===24801== 12 bytes in 3 blocks are definitely lost in loss record 3 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x80555DC: __ast_load (config.c:290) ==24801== by 0x805579A: ast_load (config.c:323) ==24801== by 0x41338213: load_module (cdr_mysql.c:99) ==24801===24801== 20 bytes in 1 blocks are definitely lost in loss record 7 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x8087DC0: node__get (key.c:463) ==24801== by 0x808798C: key_add (key.c:209) ==24801== by 0x8088442: map_init_meta (map.c:1014) ==24801===24801== 77 bytes in 11 blocks are definitely lost in loss record 20 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x42080A2B: __strdup (in /lib/i686/libc-2.2.5.so) ==24801== by 0x807A461: cli_prompt (asterisk.c:693) ==24801== by 0x8089137: prompt_print (prompt.c:99) ==24801===24801== 96 bytes in 6 blocks are definitely lost in loss record 22 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x8073F1F: ast_append_ha (acl.c:51) ==24801== by 0x4224392C: ??? (chan_iax.c:4452) ==24801== by 0x42244785: set_config (chan_iax.c:4660) ==24801===24801== 96 bytes in 1 blocks are definitely lost in loss record 23 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x808B797: term_init (term.c:342) ==24801== by 0x8087004: el_init (el.c:82) ==24801== by 0x807AAF5: ast_el_initialize (asterisk.c:873) ==24801===24801== 388 bytes in 1 blocks are definitely lost in loss record 36 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x41960E8C: ??? (chan_capi.c:1597) ==24801== by 0x4021F61B: thread_wrapper (vg_libpthread.c:667) ==24801== by 0x4016BF4F: (within /usr/local/lib/valgrind/valgrind.so) ==24801===24801== 1304 bytes in 2 blocks are definitely lost in loss record 48 of 76 ==24801== at 0x40166220: malloc (vg_clientfuncs.c:100) ==24801== by 0x43530EBD: gsm_create (in /usr/lib/asterisk/modules/codec_gsm.so) ==24801== by 0x805B9B7: calc_cost (translate.c:222) ==24801== by 0x805BE1B: ast_register_translator (translate.c:302) ==24801===24801== LEAK SUMMARY: ==24801== definitely lost: 1993 bytes in 25 blocks. ==24801== possibly lost: 0 bytes in 0 blocks. ==24801== still reachable: 332227 bytes in 2910 blocks. ==24801== suppressed: 0 bytes in 0 blocks. ==24801== Reachable blocks (those to which a pointer was found) are not shown. ==24801== To see them, rerun with: --show-reachable=yes ==24801=--24801-- TT/TC: 0 tc sectors discarded. --24801-- 11788 chainings, 0 unchainings. --24801-- translate: new 18517 (325727 -> 4243096; ratio 130:10) --24801-- discard 0 (0 -> 0; ratio 0:10). --24801-- dispatch: 15300000 jumps (bb entries), of which 1417467 (9%) were unchained. --24801-- 7295/200615 major/minor sched events. 23878 tt_fast misses. --24801-- reg-alloc: 2531 t-req-spill, 786142+24276 orig+spill uis, 92302 total-reg-r. --24801-- sanity: 6765 cheap, 271 expensive checks. --24801-- ccalls: 93666 C calls, 59% saves+restores avoided (328480 bytes) --24801-- 123669 args, avg 0.88 setup instrs each (28342 bytes) --24801-- 0% clear the stack (280998 bytes) --24801-- 28717 retvals, 31% of reg-reg movs avoided (17578 bytes) On Sunday, Mar 2, 2003, at 15:24 Europe/Oslo, Roy Sigurd Karlsbakk wrote:> hi all > > after getting some (or - a lot) of messages from nagios, claiming > asterisk > to be down, I found this out... > > astping xxx times repeatedly, and the manager fails to start. this > little > script was used for testing. below, I've pasted the output from 'ps > axfv' before and after the DoS, showing asterisk having allocated ~2GB > RAM. > > roy > > #!/usr/bin/perl -w > use strict; > my $i = 0; > while (1) { > $i++; > system("astping pbx"); > if ($? != 0) { > printf("asterisk crashed after %d astpings\n", $i); > exit; > } > } > > > ------ ps axfv before DoS > 14917 ? S 0:00 60 254 2825 1544 0.6 SCREEN > 14918 pts/3 S 0:00 302 505 2114 1008 0.3 \_ /bin/bash > 15517 pts/3 S 0:02 8023 404 91615 4800 1.8 \_ > asterisk -vvvcg > 6062 pts/3 S 0:00 1 404 91615 4800 1.8 \_ > asterisk -vv > 6063 pts/3 S 0:00 1 404 91615 4800 1.8 > \_ asterisk > 6064 pts/3 S 0:00 1 404 91615 4800 1.8 > \_ asterisk > 6066 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6067 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6068 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6069 pts/3 S 0:00 1 404 91615 4800 1.8 > \_ asterisk > 6071 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6072 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6073 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6074 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > 6075 pts/3 S 0:00 0 404 91615 4800 1.8 > \_ asterisk > > -------- ps axfv after DoS > 14917 ? S 0:00 60 254 2825 1544 0.6 SCREEN > 14918 pts/3 S 0:00 302 505 2114 1008 0.3 \_ /bin/bash > 15517 pts/3 S 0:02 8023 404 2090463 7744 3.0 \_ > asterisk -vvvc > 6062 pts/3 S 0:00 4 404 2090463 7744 3.0 \_ > asterisk - > 6063 pts/3 S 0:00 1 404 2090463 7744 3.0 > \_ asteri > 6064 pts/3 S 0:00 1 404 2090463 7744 3.0 > \_ asteri > 6066 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6067 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6068 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6069 pts/3 S 0:00 1 404 2090463 7744 3.0 > \_ asteri > 6071 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6072 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6073 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6074 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > 6075 pts/3 S 0:00 0 404 2090463 7744 3.0 > \_ asteri > > _______________________________________________ > Asterisk-Users mailing list > Asterisk-Users at lists.digium.com > http://lists.digium.com/mailman/listinfo/asterisk-users