[Home]

Summary:ASTERISK-26226: pbx: Asterisk crash on AMI action "ShowDialplan" when there's a circular dependency between contexts
Reporter:Etienne Lessard (hexanol)Labels:
Date Opened:2016-07-22 08:51:29Date Closed:2016-09-02 13:32:11
Priority:MinorRegression?
Status:Closed/CompleteComponents:Core/PBX
Versions:13.9.1 13.10.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Attachments:( 0) AST-26226.patch
( 1) backtrace.txt
Description:Given I have the following extensions.conf:
{noformat}
[C1]
include = C2
exten = 100,1,Hangup()

[C2]
include = C1
exten = 101,1,Hangup()
{noformat}
Given I have the following manager.conf:
{noformat}
[general]
enabled = yes
port = 5038

[foo]
secret = foo
write = all
deny = 0.0.0.0/0.0.0.0
permit = 127.0.0.1/255.255.255.0
{noformat}
When the AMI action "ShowDialplan" is requested with a Context and Extension argument, e.g.:
{noformat}
$ netcat 127.0.0.1 5038
Action: Login
Username: foo
Secret: foo

Action: ShowDialplan
Context: C1
Extension: 100

{noformat}
Then asterisk crash (it segfaults, caused by an "infinite" recursion)

I know circular dependencies between contexts are far from being recommended, but sometimes they exist, and I feel like asterisk should handle the case more gracefully than just crashing.

Note that the problem doesn't show up when doing a similar action via the CLI "dialplan show" command: instead, a warning "pbx.c:5442 show_dialplan_helper: Avoiding circular include of C2 within C1" is displayed
Comments:By: Asterisk Team (asteriskteam) 2016-07-22 08:51:30.489-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

By: Etienne Lessard (hexanol) 2016-07-22 08:53:41.770-0500

I've attached a backtrace generated from an Asterisk 13.10.0, but without DONT_OPTIMIZE (I felt like in this case recompiling asterisk to enable DONT_OPTIMIZE wasn't necessary...).

By: Etienne Lessard (hexanol) 2016-07-22 09:42:52.869-0500

I've attaching a quick patch I just wrote to work around the bug. It's the same implementation as the one used by the "dialplan show" CLI command, i.e. it's more or less just a copy/paste of some code from the show_dialplan_helper function to the manager_show_dialplan_helper function.

By: Joshua C. Colp (jcolp) 2016-07-24 17:02:59.293-0500

If you'd like to have this included faster you can follow the instructions on the wiki[1] to get it up for review, otherwise it will be up to someone else to go through the process which may take some time.

[1] https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process

By: Etienne Lessard (hexanol) 2016-08-29 07:23:58.841-0500

Hi Joshua,

I've finally took some time to push the patch on gerrit (and it's the first time I do so, so I had to go through a bit of documentation).

Reviewboard Link: https://gerrit.asterisk.org/3751 https://gerrit.asterisk.org/3752 https://gerrit.asterisk.org/3753 https://gerrit.asterisk.org/3754

By: Joshua C. Colp (jcolp) 2016-08-29 07:28:22.614-0500

Gerrit was having an auth problem but it has now been resolved. You can login.

By: Richard Mudgett (rmudgett) 2016-09-02 13:32:11.589-0500

Patch was merged