[Home]

Summary:ASTERISK-16416: CTRL-C from asterisk -vvvvvvvvc has strange results
Reporter:jmls (jmls)Labels:
Date Opened:2010-07-24 14:46:14Date Closed:2011-05-26 03:19:44
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:If you start asterisk from a command line (asterisk -vvvvvvc) when you press CTRL-C to end the session, you don't get local echo any more. Tried this on putty and local console.

This is not a problem with 1.4 - all works well.
Comments:By: jmls (jmls) 2010-10-02 11:58:03

checking to see if still a problem with latest 1.8 svn

By: jmls (jmls) 2010-10-02 13:25:14

Still an issue. However, it is not a problem if you start with

asterisk -r

By: Stefan Schmidt (schmidts) 2010-10-02 16:07:50

i have noticed the same over putty and mac osx terminal (ssh to same host) but i think this is allready the same with 1.6.2.
a simple "reset" (resets your bash) solves this but maybe someone has an idea why this happens.

By: Jeff Peeler (jpeeler) 2010-10-03 23:04:09

This is broken in 1.4 and occurred in commit 278981. I plan on resolving this if nobody else does, but I'll have to look at it more later.

By: Walter Doekes (wdoekes) 2010-10-04 02:27:54

I believe it is broken by the patch from https://issues.asterisk.org/view.php?id=17080 .
el_end needs to get called, but doesn't.

(gdb) break quit_handler
(gdb) run -r # or run -c
...
^C
(gdb) signal SIGINT
Breakpoint 1, quit_handler (num=0, niceness=0, safeshutdown=0, restart=0) at asterisk.c:1582
...


In the asterisk -c case:

(gdb) info threads
* 14 Thread 0x41c8f950 (LWP 22940)  quit_handler (num=0, niceness=0, safeshutdown=1, restart=0) at asterisk.c:1647
 13 Thread 0x41635950 (LWP 22939)  0x00007f6eaad86ff1 in nanosleep () from /lib/libc.so.6
 12 Thread 0x40ba0950 (LWP 22938)  0x00007f6eaadafb56 in poll () from /lib/libc.so.6
...
 2 Thread 0x40891950 (LWP 22927)  0x00007f6eaa577d29 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
 1 Thread 0x7f6eab2486f0 (LWP 22924)  0x00007f6eaadaa99b in read () from /lib/libc.so.6
(gdb) print consolethread
$1 = 140113294427888 <-- 0x7f6eab2486f0 / thread 1
(gdb) print AST_PTHREADT_NULL
$3 = 18446744073709551615
(gdb) print pthread_self()
$4 = 1103690064 <-- 0x41c8f950 / thread 14


In the asterisk -r case:

(gdb) info threads
* 1 Thread 0x7f810ceac6f0 (LWP 22958)  quit_handler (num=0, niceness=0, safeshutdown=0, restart=0) at asterisk.c:1639
(gdb) print consolethread
$1 = 18446744073709551615
(gdb) print pthread_self()
$2 = 216712944
(gdb) print AST_PTHREADT_NULL
$3 = 18446744073709551615



Undoing http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/asterisk.c?r1=278983&r2=278982&pathrev=278983 on 1.6.2.14-rc1
restores expected behaviour (resetting the terminal before leaving), but might re-introduce a crash.
I am however unable to reproduce the crash that I experienced myself (ASTERISK-16223), so the problem may have gone away through some other edit.

By: Digium Subversion (svnbot) 2010-10-07 21:35:30

Repository: asterisk
Revision: 290862

U   branches/1.4/main/asterisk.c

------------------------------------------------------------------------
r290862 | jpeeler | 2010-10-07 21:35:29 -0500 (Thu, 07 Oct 2010) | 9 lines

Ensure editline cleanup occurs when Ctrl-C is pressed at control console.

A recent change was made to avoid a race condition on shutdown which only called
the end functions from the console thread. However, when pressing Ctrl-C the
quit handler is called from the signal handler thread.

(closes issue ASTERISK-16416)
Reported by: jmls

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=290862

By: Digium Subversion (svnbot) 2010-10-07 21:45:45

Repository: asterisk
Revision: 290863

_U  branches/1.6.2/
U   branches/1.6.2/main/asterisk.c

------------------------------------------------------------------------
r290863 | jpeeler | 2010-10-07 21:45:44 -0500 (Thu, 07 Oct 2010) | 16 lines

Merged revisions 290862 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
 r290862 | jpeeler | 2010-10-07 21:35:29 -0500 (Thu, 07 Oct 2010) | 9 lines
 
 Ensure editline cleanup occurs when Ctrl-C is pressed at control console.
 
 A recent change was made to avoid a race condition on shutdown which only called
 the end functions from the console thread. However, when pressing Ctrl-C the
 quit handler is called from the signal handler thread.
 
 (closes issue ASTERISK-16416)
 Reported by: jmls
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=290863

By: Digium Subversion (svnbot) 2010-10-07 21:56:25

Repository: asterisk
Revision: 290864

_U  branches/1.8/
U   branches/1.8/main/asterisk.c

------------------------------------------------------------------------
r290864 | jpeeler | 2010-10-07 21:56:24 -0500 (Thu, 07 Oct 2010) | 23 lines

Merged revisions 290863 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2

................
 r290863 | jpeeler | 2010-10-07 21:45:44 -0500 (Thu, 07 Oct 2010) | 16 lines
 
 Merged revisions 290862 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4
 
 ........
   r290862 | jpeeler | 2010-10-07 21:35:29 -0500 (Thu, 07 Oct 2010) | 9 lines
   
   Ensure editline cleanup occurs when Ctrl-C is pressed at control console.
   
   A recent change was made to avoid a race condition on shutdown which only called
   the end functions from the console thread. However, when pressing Ctrl-C the
   quit handler is called from the signal handler thread.
   
   (closes issue ASTERISK-16416)
   Reported by: jmls
 ........
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=290864

By: Digium Subversion (svnbot) 2010-10-07 22:00:40

Repository: asterisk
Revision: 290865

_U  trunk/
U   trunk/main/asterisk.c

------------------------------------------------------------------------
r290865 | jpeeler | 2010-10-07 22:00:40 -0500 (Thu, 07 Oct 2010) | 30 lines

Merged revisions 290864 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
 r290864 | jpeeler | 2010-10-07 21:56:24 -0500 (Thu, 07 Oct 2010) | 23 lines
 
 Merged revisions 290863 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.6.2
 
 ................
   r290863 | jpeeler | 2010-10-07 21:45:44 -0500 (Thu, 07 Oct 2010) | 16 lines
   
   Merged revisions 290862 via svnmerge from
   https://origsvn.digium.com/svn/asterisk/branches/1.4
   
   ........
     r290862 | jpeeler | 2010-10-07 21:35:29 -0500 (Thu, 07 Oct 2010) | 9 lines
     
     Ensure editline cleanup occurs when Ctrl-C is pressed at control console.
     
     A recent change was made to avoid a race condition on shutdown which only called
     the end functions from the console thread. However, when pressing Ctrl-C the
     quit handler is called from the signal handler thread.
     
     (closes issue ASTERISK-16416)
     Reported by: jmls
   ........
 ................
................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=290865

By: Tilghman Lesher (tilghman) 2011-05-26 03:19:44

This patch reintroduced the race condition.  A patch which partially reverts the change that went in with this issue and instead implements a different solution without that race has been proposed in ASTERISK-17927.  Additional testing would be appreciated.