Summary:ASTERISK-16223: [patch] [regression] el_gets re-entered after el_end (at shutdown) causes segfault
Reporter:Walter Doekes (wdoekes)Labels:
Date Opened:2010-06-07 04:09:13Date Closed:2011-06-07 14:10:27
Versions:Frequency of
Environment:Attachments:( 0) astsvn-move-el_end-to-last-at-shutdown.patch
( 1) verbose-bt.txt

when running the asterisk trunk build with -c and -cv respectively, I get a segfault when hitting CTRL-C on the latter.

The cause is that el_gets (main/editline/read.c) gets re-entered after el_end has been called in quit_handler (main/asterisk.c). In el_gets, it trips on

retval = (*el->el_map.func[cmdnum]) (el, ch); // line 475

because el_map.func is NULL (cleaned by el_end).

Possible solution:
- move el_end to after all ast_verbose and ast_debug has been called as in the attached patch.

A different solution would be to fix so el_gets doesn't get called after el_end has been called.

Walter Doekes

****** STEPS TO REPRODUCE ******

$ sudo asterisk -c
(hit CTRL-C, no segfault)

$ sudo asterisk -cv
(hit CTRL-C, segfault in read.c)
Comments:By: Leif Madsen (lmadsen) 2010-06-09 10:59:33

Thanks for the patch!

By: Tilghman Lesher (tilghman) 2010-06-28 15:33:58

If you're reporting a crash, I'd like to see the backtrace, so that I can verify that any fix solves the exact problem reported.

By: Tilghman Lesher (tilghman) 2010-06-28 16:02:07

I've additionally tried to reproduce the crash you've described, and I cannot.

By: Walter Doekes (wdoekes) 2010-06-29 00:19:03

See the backtrace in 0017490.

By: Walter Doekes (wdoekes) 2010-06-29 00:36:32

verbose-bt.txt is a more verbose backtrace of the crash with r268572.

I've tried to compile latest trunk, but res_ais.c breaks the build, so I cannot confirm or deny that the bug is still there.


;; vim: set syntax=asterisk:
;; (file-mandatory)

appendhostname=no ; (append hostname to logfiles)
dateformat=%F %T ; (ISO 8601: yyyy-mm-dd HH:MM:SS)
event_log=no ; (log generic events)
queue_log=no ; (log queue events)
rotatestrategy=rotate ; (sequential, rotate or timestamp)
exec_after_rotate=gzip -9 ${filename}.2

console => debug,verbose,notice,warning,error
debug.log => debug,verbose
messages.log = notice,warning,error
syslog.local0 => warning,error

By: Walter Doekes (wdoekes) 2010-06-29 01:02:08

Ok, unbreaking the build was a matter of make-distclean.

Yes. The bug does _not_ appear in r272961.

By: Tilghman Lesher (tilghman) 2010-06-29 10:03:43

Already fixed in SVN.