[asterisk-dev] [Code Review] Prevent segfault when asterisk restarts. Happens if call arrives before fully booted.

Alec Davis reviewboard at asterisk.org
Fri Sep 2 15:25:06 CDT 2011


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1407/
-----------------------------------------------------------

(Updated Sept. 2, 2011, 3:25 p.m.)


Review request for Asterisk Developers.


Changes
-------

My crashes followed this path.

#0  0xb753d4cb in strlen () from /lib/i686/cmov/libc.so.6
#1  0xb750a1e4 in vfprintf () from /lib/i686/cmov/libc.so.6
#2  0xb752e464 in vsnprintf () from /lib/i686/cmov/libc.so.6
#3  0x081966ed in __ast_str_helper (buf=0xb4713648, max_len=8192, append=0, fmt=0xb4eb367c "ALEC opt_args[OPT_ARG_PRIVACY] = '%s'\n",
    ap=0xb47136b4 "ÿÿÿÿHKq´^¹ê´èq1\017à ë´C5ë´\a\b") at strings.c:72
#4  0x081a7737 in ast_str_set_va (buf=0xb4713648, max_len=8192, fmt=0xb4eb367c "ALEC opt_args[OPT_ARG_PRIVACY] = '%s'\n",
    ap=0xb47136b4 "ÿÿÿÿHKq´^¹ê´èq1\017à ë´C5ë´\a\b") at /usr/src/pbx/jan2011/asterisk/include/asterisk/strings.h:776
#5  0x0812ba13 in ast_log (level=2, file=0xb4eb20d4 "app_dial.c", line=2066, function=0xb4eb3543 "dial_exec_full",
    fmt=0xb4eb367c "ALEC opt_args[OPT_ARG_PRIVACY] = '%s'\n") at logger.c:1229
#6  0xb4eabbd6 in dial_exec_full (chan=0xf316aa8, data=0xb4716d48 "DAHDI/r0/4866", peerflags=0xb4714b6c, continue_exec=0x0) at app_dial.c:2066
#7  0xb4eb1655 in dial_exec (chan=0xf316aa8, data=0xb4716d48 "DAHDI/r0/4866") at app_dial.c:2926
#8  0x0814706e in pbx_exec (c=0xf316aa8, app=0xf1d2858, data=0xb4716d48 "DAHDI/r0/4866") at pbx.c:1547
#9  0x081502fd in pbx_extension_helper (c=0xf316aa8, con=0x0, context=0xf317198 "trusted", exten=0xf3171e8 "4866", priority=2, label=0x0,
    callerid=0xf270720 "GXP0001", action=E_SPAWN, found=0xb4719258, combined_find_spawn=1) at pbx.c:4270
#10 0x0815219c in set_ext_pri (c=0xf316aa8, exten=0xf317198 "trusted", pri=254898664) at pbx.c:4919
#11 0x08152b45 in __ast_pbx_run (c=0xf316aa8, args=0x0) at pbx.c:5015
#12 0x081546e4 in pbx_thread (data=0xf316aa8) at pbx.c:5350
#13 0x081a947e in dummy_start (data=0xf275af0) at utils.c:1007
#14 0xb73084c0 in start_thread () from /lib/i686/cmov/libpthread.so.0
#15 0xb75a784e in clone () from /lib/i686/cmov/libc.so.6

so to avoid the can of worms, instead of checking whether we're fullybooted in __ast_pbx_run, i could move it out to pbx_thread.


Summary
-------

If a call arrives before asterisk is fully booted generally it will segfault.


Diffs (updated)
-----

  trunk/main/pbx.c 333893 

Diff: https://reviewboard.asterisk.org/r/1407/diff


Testing
-------

restarted asterisk, and before all modules have finished loading made a call into it.
Warnign message appears, and call is dropped.
No orpaned channels.


Thanks,

Alec

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20110902/653f29e8/attachment.htm>


More information about the asterisk-dev mailing list