[Asterisk-Users] Segfault when parking from extension dialed inside AGI.

Luis Vazquez luis at teledata.com.uy
Wed Mar 3 09:35:34 MST 2004


Hello all,

Asterisk is segfault dying when I try to park a call from an extension 
dialed from an AGI script.
The situation is as follows:
I call from a sip phone (really It doesn't matter if It's SIP or not) to 
extension 181 (corresponding to a mgcp DG-104S phone).
.....
exten => 181,1,AGI(dummydial.agi,MGCP/aaln/1 at mgcp01)
.....
dummydial.agi is only a simplified test script I made to isolate the 
problem, It only makes a dial to the given channel:
#############################################################
#!/usr/bin/perl
# dummydial.agi: Marcar internos con AGI
use strict;
use Asterisk::AGI;

local $::INPUT_RECORD_SEPARATOR="\n";
local $::OUTPUT_AUTOFLUSH=1;

my $agi = new Asterisk::AGI;
my %input = $agi->ReadParse();
my ($dialstring) = shift @ARGV;

$agi->verbose("Dialing: $dialstring",1);
my $ret = $agi->exec('Dial',"$dialstring|40|t");
# $ret = $agi->exec('Macro',"generic_dial|$dialstring|$vm");  # This is 
the real thing, crashes to
# exit 0;
##################################################################

then I peak the phone and the call is established perfectly. 
Then I want to park the call with the following configuration at 
parking.conf:
###################################
[general]
parkext => 700                          ; What ext. to dial to park
parkpos => 701-720                      ; What extensions to park calls on
context => parkedcalls                  ; Which context parked calls are in
parkingtime => 120                      ; Number of seconds a call can 
be parked
####################################

so from the called extension (181) I press (#) I do hear "transfer" and 
then I dial 700.
Then the voice tell mi the call is parked at extension 701, but as soon 
as I hangup the called phone
and try to peak the parked call (and sometimes even before) Asterisk 
dies with segmentation fault.
As I said before It doesn't depend if I made a call from SIP to SIP or 
MGCP to SIP or MGCP to MGCP extension.
The final result (the server crashing with segfault) is always the same.
However If I do exactly the same but with the extension dialing directly 
from extensions.conf with:
exten => 183,1,Dial(MGCP/aaln/4 at mgcp01,40,tr)
the parking and recovering of the calls works correctly without any problem.

This is the output on the console:
=========================================================================
*CLI>     -- Executing AGI("SIP/ipcontact.com.uy-0817d0c0", 
"dummydial.agi|MGCP/aaln/1 at mgcp01") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/dummydial.agi
  dummydial.agi|MGCP/aaln/1 at mgcp01: Dialing: MGCP/aaln/1 at mgcp01
    -- AGI Script Executing Application: (Dial) Options: 
(MGCP/aaln/1 at mgcp01|40|t)
    -- MGCP mgcp_request(aaln/1 at mgcp01)
    -- MGCP cw: -1, dnd: 0, so: 0, sno: 0
    -- MGCP mgcp_new(MGCP/aaln/1 at mgcp01-1) created in state: Down
    -- Called aaln/1 at mgcp01
    -- MGCP/aaln/1 at mgcp01-1 is ringing
    -- Endpoint 'aaln/1 at mgcp01-1' observed 'hd'
    -- MGCP/aaln/1 at mgcp01-1 answered SIP/ipcontact.com.uy-0817d0c0
    -- Attempting native bridge of SIP/ipcontact.com.uy-0817d0c0 and 
MGCP>/aaln/1 at mgcp01-1
Mar  3 16:07:42 NOTICE[458781]: rtp.c:264 process_rfc3389: RFC3389 
support incomplete.  Turn off on client if possible
    -- Endpoint 'aaln/1 at mgcp01-1' observed '#'
    -- Started music on hold, class 'default', on 
SIP/ipcontact.com.uy-0817d0c0
    -- Playing 'pbx-transfer' (language 'en')
    -- Endpoint 'aaln/1 at mgcp01-1' observed '7'
    -- Endpoint 'aaln/1 at mgcp01-1' observed '0'
    -- Endpoint 'aaln/1 at mgcp01-1' observed '0'
    -- Stopped music on hold on SIP/ipcontact.com.uy-0817d0c0
    -- Started music on hold, class 'default', on 
SIP/ipcontact.com.uy-0817d0c0
  == Parked SIP/ipcontact.com.uy-0817d0c0 on 701
    -- Playing 'digits/7' (language 'en')
    -- Playing 'digits/0' (language 'en')
    -- Playing 'digits/1' (language 'en')
    -- AGI Script dummydial.agi completed, returning 0
    -- Endpoint 'aaln/1 at mgcp01-1' observed 'hu'
    -- MGCP handle_request(aaln/1 at mgcp01-1) ast_channel already destroyed
    -- MGCP handle_request(aaln/1 at mgcp01) set vmwi(-)
    -- Endpoint 'aaln/1 at mgcp01-1' observed 'hd'
    -- MGCP mgcp_new(MGCP/aaln/1 at mgcp01-1) created in state: Down
    -- Endpoint 'aaln/1 at mgcp01-1' observed '7'
    -- Endpoint 'aaln/1 at mgcp01-1' observed '0'
    -- Endpoint 'aaln/1 at mgcp01-1' observed '1'
    -- Executing ParkedCall("MGCP/aaln/1 at mgcp01-1", "701") in new stack
    -- MGCP mgcp_answer(MGCP/aaln/1 at mgcp01-1) on aaln/1 at mgcp01-1
    -- Stopped music on hold on SIP/ipcontact.com.uy-0817d0c0
    -- Channel MGCP/aaln/1 at mgcp01-1 connected to parked call 701
    -- Attempting native bridge of SIP/ipcontact.com.uy-0817d0c0 and 
MGCP/aaln/1 at mgcp01-1
Mar  3 16:07:53 WARNING[475166]: channel.c:846 ast_waitfor_nandfds: 
Thread 475166 Blocking 'SIP/ipcontact.com.uy-0817d0c0', already blocked 
by thread 458781 in procedure ast_waitfor_nandfds
Mar  3 16:07:54 WARNING[491551]: channel.c:846 ast_waitfor_nandfds: 
Thread 491551 Blocking 'SIP/ipcontact.com.uy-0817d0c0', already blocked 
by thread 458781 in procedure ast_waitfor_nandfds
......... MANY, MANY OF THIS ................
...................................................................
Mar  3 16:07:55 WARNING[491551]: channel.c:1364 ast_write: Thread 491551 
Blocking 'SIP/ipcontact.com.uy-0817d0c0', already blocked by thread 
458781 in procedure ast_waitfor_nandfds
    -- Timeout on SIP/ipcontact.com.uy-0817d0c0
  == CDR updated on SIP/ipcontact.com.uy-0817d0c0
    -- Executing Hangup("SIP/ipcontact.com.uy-0817d0c0", "") in new stack
  == Spawn extension (local, t, 1) exited non-zero on 
'SIP/ipcontact.com.uy-0817d0c0'
    -- Executing GotoIf("SIP/ipcontact.com.uy-0817d0c0", "1?4") in new stack
    -- Goto (local,h,4)
    -- Executing NoOp("SIP/ipcontact.com.uy-0817d0c0", "") in new stack
Ouch ... error while writing audio data: : Broken pipe
Segmentation fault
========================================================================

Does anybody knows a fix for this, or if there is a work around for this. 
I need to use AGI to handle the extensions because this is the only way 
(I guess) of doing something  interesting and dynamic with the calls 
(for example using a DB to keep the extensions information).
I thought about using  SET CONTEXT and SET EXTENSION and then make the 
dial from a special context, but then I have no easy way to access the 
other extensions (for example to make a transfer) from the called one.

We already made a bug report on this topic.

Thanks in advance for any help
Luis





More information about the asterisk-users mailing list