Summary:ASTERISK-19764: Infinite loop with autoservice when looking for nonexistant extension label.
Reporter:Richard Mudgett (rmudgett)Labels:
Date Opened:2012-04-20 16:45:21Date Closed:2012-06-01 18:22:20
Status:Closed/CompleteComponents:Applications/app_stack Resources/res_agi
Versions:SVN Frequency of
Environment:Attachments:( 0) bt_full.txt
( 1) bt.txt
( 2) core_show_locks.txt
( 3) dial_123.pl
( 4) extensions.conf
( 5) version.txt
Description:Running an AGI script that passes an invalid extension priority label to the Gosub application occasionally causes an infinite loop when removing a channel from autoservice.  The AGI gosub call is searching for the non-existent extension priority label 'agi_gosub'.

Steps to reproduce:
1) Call extension 123@sip_site_b
2) Repeat if necessary for deadlock.

Thread 2 in the backtrace is the stuck thread.  It is waiting in ast_autoservice_stop() for autoservice to complete updating its list.
Comments:By: Richard Mudgett (rmudgett) 2012-05-29 16:27:05.899-0500

The gosub_exec() is holding the channel lock when it is looking for the extension label.  Unfortunately, the channel lock cannot be held while looking in the dialplan for the gosub target because the channel can be put into autoservice.

The channel lock needs to be released when calling ast_parseable_goto() and ast_exists_extension().  The channel then needs to be relocked when setting the new dialplan execution location.