Summary:ASTERISK-01763: Quicknet Internet Phonejack crashes asterisk on incomming calls
Reporter:tormez (tormez)Labels:
Date Opened:2004-06-04 08:29:51Date Closed:2008-01-15 14:57:39.000-0600
Versions:Frequency of
Environment:Attachments:( 0) chan_phone.patch2_cid.txt
( 1) cid.c
Description:In my extensions.conf, I have:
exten => s,4,Dial(Phone/phone0,15)

Once the caller get's to this point asterisk then crashes with the following error:

/usr/sbin/safe_asterisk: line 77:  5202 Segmentation fault      asterisk ${ASTARGS} 1>&/dev/${TTY} </dev/${TTY}
Asterisk ended with exit status 139
Asterisk exited on signal 11.

Outbound calls from this device work perfectly OK.


I have installed the ixj-3.1.0 from source
I am using Asterisk CVS-HEAD-06/04/04-07:08:03
Comments:By: khb (khb) 2004-06-04 12:10:34

Which codec are you using with the card?
What's the OS?
Do you have a stack trace?

By: tormez (tormez) 2004-06-04 13:20:11

I'm using format=slinear in my phone.conf

I'm running gentoo linux

I'm not sure how to get a stack trace, how would i got about doing that?

By: khb (khb) 2004-06-05 02:43:56

Try using format=ulaw  codec
if it works stick with it.

if that crashes too, try this:

gdb asterisk
set args -vvvgc

By: tormez (tormez) 2004-06-05 06:17:23

I will test this on monday, and send the results

By: supaplex (supaplex) 2004-06-06 01:28:28

I have a backtrace, and experience the same issue.  The phone in the backtrace has been masked on the final four (privacy).  asterisk was started with safe_asterisk, and the master pid was attached.  I am running debian woody.  I initally receive a call on my x100p card on asterisk1 which uses IAX trunking to forward the call to asterisk2 to the fxo quicknet isa phonejack.  I've not had this encounter from other callers.  device is running in format=slinear.  I have changed to =ulaw and will post an update if I can reproduce it again.

# gdb asterisk 6893
[-- after dozens upon dozens of lines about modules and lib's loaded... --]
(gdb) continue
[New Thread 12301 (LWP 6917)]
[New Thread 13326 (LWP 6918)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 12301 (LWP 6917)]
0x40111783 in strncpy () from /lib/libc.so.6
(gdb) where
#0  0x40111783 in strncpy () from /lib/libc.so.6
#1  0x404c0708 in phone_call (ast=0x8125460, dest=0xbe1fe7a4 "phone0", timeout=0) at chan_phone.c:179
#2  0x0805ca5e in ast_call (chan=0x8125460, addr=0xbe1fe7a4 "phone0", timeout=0) at channel.c:1893
#3  0x404d53f1 in dial_exec (chan=0x8123c50, data=0xbe1fed24) at app_dial.c:759
#4  0x0806ce9c in pbx_exec (c=0x8123c50, app=0x80ea740, data=0xbe1fed24, newstack=1) at pbx.c:424
ASTERISK-1  0x0806ee40 in pbx_extension_helper (c=0x8123c50, context=0x8123da8 "macro-stdexten", exten=0x8123e9c "s", priority=1, callerid=0x80fcd30 "801885XXXX", action=1) at pbx.c:1207
ASTERISK-2  0x0807562e in ast_spawn_extension (c=0x8123c50, context=0x8123da8 "macro-stdexten", exten=0x8123e9c "s", priority=1, callerid=0x80fcd30 "801885XXXX") at pbx.c:1691
ASTERISK-3  0x405553f8 in macro_exec (chan=0x8123c50, data=0xbe1ff774) at app_macro.c:141
ASTERISK-4  0x0806ce9c in pbx_exec (c=0x8123c50, app=0x8116c90, data=0xbe1ff774, newstack=1) at pbx.c:424
ASTERISK-5  0x0806ee40 in pbx_extension_helper (c=0x8123c50, context=0x8123da8 "macro-stdexten", exten=0x8123e9c "s", priority=1, callerid=0x80fcd30 "801885XXXX", action=1) at pbx.c:1207
ASTERISK-6 0x0806fb4e in ast_pbx_run (c=0x8123c50) at pbx.c:1691
ASTERISK-7 0x08075f16 in pbx_thread (data=0x8123c50) at pbx.c:1916
ASTERISK-8 0x400200ba in pthread_start_thread () from /lib/libpthread.so.0
ASTERISK-9 0x40020101 in pthread_start_thread_event () from /lib/libpthread.so.0
(gdb) ^d
A debugging session is active.
Do you still want to close the debugger?(y or n) y
Detaching from program: /usr/sbin/asterisk, process 6893
/usr/sbin/safe_asterisk: line 82:  6893 Segmentation fault      asterisk ${ASTARGS} 1>&/dev/${TTY} </dev/${TTY}
Asterisk ended with exit status 139
Asterisk exited on signal 11.
Automatically restarting Asterisk.

edited on: 06-06-04 01:14

By: Mark Spencer (markster) 2004-06-06 01:59:47

Please cvs update to latest cvs *head* and let me know if that fixes it.  I don't have a PhoneJack to test with but I think i see where the problem is.

By: khb (khb) 2004-06-06 14:41:53

I don't think that will fix it.
The code has been working fine for many months under RH9 and the CVS checkout of the quicknet driver.
There is something deeper going on here.
I checked out this version 3.1.0 and it turns out that this is more recent than the CVS which claims always to be the latest version.
I will be testing it...

By: Mark Spencer (markster) 2004-06-06 15:49:16

I made a change to CVS head that I think will solve the problem based upon the backtrace that supaplex provided.  If your problem is the same as his, it's likely to be fixed.

If you can provide a backtrace based upon latest CVS head, that would certainly be helpful, but at the very least, when I make a change to the code to address a bug, please take the time to test the code before adding a comment suggesting it won't work.

By: khb (khb) 2004-06-06 19:38:00

Sorry Mark,
didn't mean to jump the gun,
only meant to point out that there are likely problems with the 3.1.0 ixj driver.
I never had any crashes with the current driver, but it seems I was just lucky.

There were two problems, the old cid code in chan_phone.c assumed that the cid was already preprocessed and in standard format. Although I have never seen an incomplete CID here and never could see the failure, I see that others do get incomplete CID's passed into the driver. This is indeed fixed in your patch and it should eliminate the crash.  However, it still doesn't display the called id correctly. You need to remove the 'sizeof(x) - 1' restriction in the strncopy routines.
What's worse is that this 3.1.0 ixj driver seems to have broken the caller id display altogether. It just doesn't send any.  The quicknet SDK cidring example also fails with this driver.
Under an OS other than __linux__, i.e. for FreeBSD etc., the ioctl call to display the CID passes the CID structure directly and not the address to it. I don't know if this causes a segfault as well, since I can't produce it right now.
I am adding a new patch to be applied against the cvs as of now. Please add it.
It makes the changes for FreeBSD with the new driver, which it senses by a symbol which is not present in the older driver header files, and it fixes the display problems as well.  In addition, the patch now lets the driver send the default caller id (and time and date) even when the channel callerid field was NULL, previously it didn't inititialize the CID structure at all.

For those who want/need working CAller ID (at least under RH9 -- perhaps it works elsewhere, please test with the utility below), they should run the driver from CVS depository at openh323.org, until we can figure out what's broken in 3.1.0.
3.1.0 does have some nice features, include more devices support and easy to use debugging features.

--file attached

edited on: 06-06-04 21:25

edited on: 06-06-04 21:26

By: khb (khb) 2004-06-06 20:12:23

Added a file cid.c, which is a little test program to debug caller id problems with quicknet cards in the context of chan_phone.c.
Run it as follows:
cc -o cid cid.c
./cid '"my name" <17005551212>'

edited on: 06-06-04 19:58

By: tormez (tormez) 2004-06-07 06:37:09

w00t!.. i updated asterisk and everything worked fine.  The only thing that didn't work was that i had to use the format=slinear in the phone.conf.  Using format=ulaw gave me an input/output error.

You are the man!

edited on: 06-07-04 06:32

By: khb (khb) 2004-06-07 12:03:23

ok, that's for Mark.
Input/output error?  Do you have some printed output of that? From my experience ulaw works very well with the card, but supaplex said that it was even worse than slinear. Seems to be highly dependent on the environment, eg. OS etc.
Is callerid displayed correctly--at all?-- for you?

By: tormez (tormez) 2004-06-08 14:52:03

This is exactly what happens when I use ulaw for the compression.

   -- Called phone0
   -- Phone/phone0 is ringing
   -- Phone/phone0 answered Zap/1-1
   -- Playing 'queue-support' (language 'en')
Jun  8 15:11:09 WARNING[245776]: chan_phone.c:435 phone_read: Error reading: Input/output error
Jun  8 15:11:09 WARNING[245776]: app_queue.c:1048 try_calling: Agent on Phone/phone0 hungup on the customer.  They're going to be pissed.
   -- Hungup 'Phone/phone0'

I don't have caller id on these lines to test that.

edited on: 06-08-04 14:38

By: Mark Spencer (markster) 2004-06-08 17:06:57

Since the crash is fixed I"ll go ahead and close this out.  If you have other minor issues, you can open a new ticket.

By: Digium Subversion (svnbot) 2008-01-15 14:57:24.000-0600

Repository: asterisk
Revision: 3154

U   trunk/channels/chan_phone.c

r3154 | markster | 2008-01-15 14:57:24 -0600 (Tue, 15 Jan 2008) | 2 lines

Try to parse callerid properly on /dev/phone (bug ASTERISK-1763)



By: Digium Subversion (svnbot) 2008-01-15 14:57:39.000-0600

Repository: asterisk
Revision: 3172

U   trunk/channels/chan_phone.c

r3172 | markster | 2008-01-15 14:57:39 -0600 (Tue, 15 Jan 2008) | 2 lines

chan_phone portability (bug ASTERISK-1763)