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

Luis Vazquez luis at teledata.com.uy
Wed Mar 3 10:33:53 MST 2004


Hello again
After a few minutes of thinking (usefull sometimes :) I solved the 
problem of using the AGI to make the dialing decision while avoid doing 
the dial from inside the agi application without changing context (to 
keep access to other extensions using transfer).
Very simple, using SET PRIORITY together with SET VARIABLE  after I get  
the needed information,
and then exiting from agi before doing the Dial.
Something like this:

[macro-generic_dial]
;   ${ARG1} - Extension
;
exten => s,1,AGI(gotodial.agi,${ARG1})
exten => s,2,Hangup
exten => s,3,Dial(${DIALCHANNEL},40,tr) ; Ring the selected channel 40 
seconds
exten => s,4,GotoIf($[${VMBOX} = 0]?4:3)
exten => s,5,VoiceMail(u${VMBOX}@default) ; If unavailable, send to 
voicemail
exten => s,6,Hangup                             ; Hangup the call
exten => s,104,GotoIf($[${VMBOX} = 0]?104:103)
exten => s,105,VoiceMail(b${VMBOX}@default)     ; If busy, send to voicemail
exten => s,106,Hangup                           ; Hangup the call

[default]
;; Generic extention dialing
exten => _1XX,1,Macro(generic_dial,${EXTEN})

And using something like this inside the gotodial.agi script:
.............................
                    $agi->database_put("LastDial", $callinExten, 
$exten);  # To implement call return
                    $agi->verbose("Dialing: $dialstring",1);
                    $agi->set_variable('DIALCHANNEL',"$dialstring");
                    $agi->set_variable('VMBOX',"$vm");
                    $agi->set_priority('3');
                    exit 0;
..............................

Anyway It would be nice If asterisk didn't die so easily (h323 transfer, 
agi dial and parking, openswitch channel's driver, speaking too loudly 
next to the server, etc)
Best regards
Luis



Luis Vazquez wrote:

> 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
>
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users






More information about the asterisk-users mailing list