[Home]

Summary:ASTERISK-13704: exten => ANSWER not found when extenpatternmatchnew=yes
Reporter:Johann Steinwendtner (steinwej)Labels:
Date Opened:2009-03-06 09:25:11.000-0600Date Closed:2010-03-03 13:43:07.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/PBX
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Upgraded from 1.4 to 1.6.0.6, dialplan from 1.4 tested with extenpatternmatchnew=yes

[from_meridian_test]
exten => 333,1,NoOp(Starting Test, exten 333)
exten => 333,n,Goto(answer,1)
exten => 333,n,Hangup

exten => answer,1,NoOp(Test no answer)
exten => answer,n,Playback(vm-goodbye)
exten => answer,n,Hangup

exten => is-BUSY,1,NoOp(Test now busy)
exten => is-BUSY,n,Playback(vm-goodbye)
exten => is-BUSY,n,Hangup

A call to the above 333 results in a Goto(answer,1) and everything is expected.

But when I change this to the following dialplan, the exten is not found:

[from_meridian_test]
exten => 333,1,NoOp(Starting Test, exten 333)
exten => 333,n,Goto(ANSWER,1)
exten => 333,n,Hangup

exten => ANSWER,1,NoOp(Test no answer)
exten => ANSWER,n,Playback(vm-goodbye)
exten => ANSWER,n,Hangup

exten => is-BUSY,1,NoOp(Test now busy)
exten => is-BUSY,n,Playback(vm-goodbye)
exten => is-BUSY,n,Hangup

this results in:

*CLI> console dial 333@from_meridian_test
 == Console is full duplex
*CLI> [Mar  6 16:20:15] NOTICE[6474]: console_video.c:130 console_video_start: voice only, console video support not present
   -- Executing [333@from_meridian_test:1] NoOp("Console/dsp", "Starting Test, exten 333") in new stack
   -- Executing [333@from_meridian_test:2] Goto("Console/dsp", "ANSWER,1") in new stack
   -- Goto (from_meridian_test,ANSWER,1)
[Mar  6 16:20:15] WARNING[6513]: pbx.c:3769 __ast_pbx_run: Channel 'Console/dsp' sent into invalid extension 'ANSWER' in context 'from_meridian_test', but no invalid handler
<< Hangup on console >>

But show dialplan gives:
*CLI> dialplan show from_meridian_test
[ Context 'from_meridian_test' created by 'pbx_config' ]
 '333' =>          1. NoOp(Starting Test, exten 333)             [pbx_config]
                   2. Goto(ANSWER,1)                             [pbx_config]
                   3. Hangup()                                   [pbx_config]
 'ANSWER' =>       1. NoOp(Test no answer)                       [pbx_config]
                   2. Playback(vm-goodbye)                       [pbx_config]
                   3. Hangup()                                   [pbx_config]
 'is-BUSY' =>      1. NoOp(Test now busy)                        [pbx_config]
                   2. Playback(vm-goodbye)                       [pbx_config]
                   3. Hangup()                                   [pbx_config]

-= 3 extensions (9 priorities) in 1 context. =-


Further testing shows: exten => Answer works o.k. but exten => ANswer does not work anymore

So, I can not evaluate DIALSTATUS after dial.
Comments:By: Mark Michelson (mmichelson) 2009-03-06 15:13:16.000-0600

I have a distinct feeling that the problem is that when extenpatternmatchnew is enabled, the parser doesn't realize that the extension ANSWER is not a pattern, but a literal name. The capital 'N' is being used there to mean any digit 2-9 instead of the literal letter 'N', and thus the word ANSWER does not match the pattern _ANSWER.

By: Mark Michelson (mmichelson) 2009-03-06 15:18:02.000-0600

Confirmed. If I change your failing dialplan to the following, it works:

exten => 333,1,NoOp(Starting Test, exten 333)
exten => 333,n,Goto(A5SWER,1)
exten => 333,n,Hangup

exten => ANSWER,1,NoOp(Test no answer)
exten => ANSWER,n,Playback(vm-goodbye)
exten => ANSWER,n,Hangup

If it's not clear, I changed the 'N' in the Goto to a 5. Since it is a digit in the 2-9 range, it matches the pattern _ANSWER, and things work as expected.

By: Mark Michelson (mmichelson) 2009-03-11 09:39:19

I started a branch in svn to help fix the problems I've been coming across while inspecting the extenpatternmatchnew logic. If you're interested, the branch can be checked out using subversion from:

http://svn.digium.com/svn/asterisk/team/mmichelson/npm_fixes

So far, in addition to the problem presented here, I've found several others and have fixed them too. At this point the biggest thing I'm dealing with is a potential memory leak. Most of the actual problems relating to pattern-matching appear to be fixed for the most part now.

By: Mark Michelson (mmichelson) 2009-03-11 09:40:24

Oh, and by the way, the branch that I linked to is based off of Asterisk trunk, not 1.6.0, so I wouldn't recommend using it in production or for anything "mission-critical." However, if all you're doing is testing that your dialplan extensions are dialled correctly, then it is a fine branch to use.

By: Johann Steinwendtner (steinwej) 2009-03-12 05:47:15

I've testet ANswer, BusZy, and BusX extensions, and they seem to match correctly now. Thanks. But I'm not able to test if your code leaks. Thanks.

By: Mark Michelson (mmichelson) 2009-03-13 16:08:39

I tracked down what I thought was the memory leak. It turns out that there isn't one at all. I thought that the pattern match tree was being created twice for one of my contexts, but it turns out that it was being created when app_queue was trying to poll the device state of some local channels, then was getting deleted when the context merging operation was done when the dialplan was loaded. Once the dialplan is loaded, there is a more "permanent" context loaded into memory which needs the pattern-matching tree created for it, so we create the pattern match tree for this context. This is the pattern match tree which stays in memory until the dialplan is reloaded.

So, the memory that I thought was leaking was properly being freed after all. Since my tests are running well, I went ahead and posted a code review at http://reviewboard.digium.com/r/194/

After re-reading your latest note, I realize that the comment I made in the "testing done" section about your testing with your dialplan may not be 100% accurate, but you did test some things that I did not.

By: Digium Subversion (svnbot) 2009-04-17 08:29:34

Repository: asterisk
Revision: 188901

U   trunk/main/pbx.c

------------------------------------------------------------------------
r188901 | mmichelson | 2009-04-17 08:29:33 -0500 (Fri, 17 Apr 2009) | 27 lines

Several fixes to the extenpatternmatchnew logic.

1. Differentiate between literal characters in an extension
and characters that should be treated as a pattern match. Prior to
these fixes, an extension such as NNN would be treated as a pattern,
rather than a literal string of N's.

2. Fixed the logic used when matching an extension with a bracketed
expression, such as 2[5-7]6.

3. Removed all areas of code that were executed when NOT_NOW was
#defined. The code in these areas had the potential to crash, for
one thing, and the actual intent of these blocks seemed counterproductive.

4. Fixed many many coding guidelines problems I encountered while looking
through the corresponding code.

5. Added failure cases and warning messages for when duplicate extensions
are encountered.

6. Miscellaneous fixes to incorrect or redundant statements.

(closes issue ASTERISK-13704)
Reported by: steinwej
Tested by: mmichelson


------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=188901

By: Digium Subversion (svnbot) 2009-04-17 08:30:11

Repository: asterisk
Revision: 188901

U   trunk/main/pbx.c

------------------------------------------------------------------------
r188901 | mmichelson | 2009-04-17 08:29:33 -0500 (Fri, 17 Apr 2009) | 28 lines

Several fixes to the extenpatternmatchnew logic.

1. Differentiate between literal characters in an extension
and characters that should be treated as a pattern match. Prior to
these fixes, an extension such as NNN would be treated as a pattern,
rather than a literal string of N's.

2. Fixed the logic used when matching an extension with a bracketed
expression, such as 2[5-7]6.

3. Removed all areas of code that were executed when NOT_NOW was
#defined. The code in these areas had the potential to crash, for
one thing, and the actual intent of these blocks seemed counterproductive.

4. Fixed many many coding guidelines problems I encountered while looking
through the corresponding code.

5. Added failure cases and warning messages for when duplicate extensions
are encountered.

6. Miscellaneous fixes to incorrect or redundant statements.

(closes issue ASTERISK-13704)
Reported by: steinwej
Tested by: mmichelson

Review: http://reviewboard.digium.com/r/194/

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=188901

By: Digium Subversion (svnbot) 2009-04-17 08:30:43

Repository: asterisk
Revision: 188902

_U  branches/1.6.0/

------------------------------------------------------------------------
r188902 | mmichelson | 2009-04-17 08:30:43 -0500 (Fri, 17 Apr 2009) | 34 lines

Blocked revisions 188901 via svnmerge

........
 r188901 | mmichelson | 2009-04-17 08:29:33 -0500 (Fri, 17 Apr 2009) | 28 lines
 
 Several fixes to the extenpatternmatchnew logic.
 
 1. Differentiate between literal characters in an extension
 and characters that should be treated as a pattern match. Prior to
 these fixes, an extension such as NNN would be treated as a pattern,
 rather than a literal string of N's.
 
 2. Fixed the logic used when matching an extension with a bracketed
 expression, such as 2[5-7]6.
 
 3. Removed all areas of code that were executed when NOT_NOW was
 #defined. The code in these areas had the potential to crash, for
 one thing, and the actual intent of these blocks seemed counterproductive.
 
 4. Fixed many many coding guidelines problems I encountered while looking
 through the corresponding code.
 
 5. Added failure cases and warning messages for when duplicate extensions
 are encountered.
 
 6. Miscellaneous fixes to incorrect or redundant statements.
 
 (closes issue ASTERISK-13704)
 Reported by: steinwej
 Tested by: mmichelson
 
 Review: http://reviewboard.digium.com/r/194/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=188902

By: Digium Subversion (svnbot) 2009-04-17 08:30:57

Repository: asterisk
Revision: 188903

_U  branches/1.6.1/

------------------------------------------------------------------------
r188903 | mmichelson | 2009-04-17 08:30:57 -0500 (Fri, 17 Apr 2009) | 34 lines

Blocked revisions 188901 via svnmerge

........
 r188901 | mmichelson | 2009-04-17 08:29:33 -0500 (Fri, 17 Apr 2009) | 28 lines
 
 Several fixes to the extenpatternmatchnew logic.
 
 1. Differentiate between literal characters in an extension
 and characters that should be treated as a pattern match. Prior to
 these fixes, an extension such as NNN would be treated as a pattern,
 rather than a literal string of N's.
 
 2. Fixed the logic used when matching an extension with a bracketed
 expression, such as 2[5-7]6.
 
 3. Removed all areas of code that were executed when NOT_NOW was
 #defined. The code in these areas had the potential to crash, for
 one thing, and the actual intent of these blocks seemed counterproductive.
 
 4. Fixed many many coding guidelines problems I encountered while looking
 through the corresponding code.
 
 5. Added failure cases and warning messages for when duplicate extensions
 are encountered.
 
 6. Miscellaneous fixes to incorrect or redundant statements.
 
 (closes issue ASTERISK-13704)
 Reported by: steinwej
 Tested by: mmichelson
 
 Review: http://reviewboard.digium.com/r/194/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=188903

By: Digium Subversion (svnbot) 2009-04-17 08:31:07

Repository: asterisk
Revision: 188904

_U  branches/1.6.2/

------------------------------------------------------------------------
r188904 | mmichelson | 2009-04-17 08:31:07 -0500 (Fri, 17 Apr 2009) | 34 lines

Blocked revisions 188901 via svnmerge

........
 r188901 | mmichelson | 2009-04-17 08:29:33 -0500 (Fri, 17 Apr 2009) | 28 lines
 
 Several fixes to the extenpatternmatchnew logic.
 
 1. Differentiate between literal characters in an extension
 and characters that should be treated as a pattern match. Prior to
 these fixes, an extension such as NNN would be treated as a pattern,
 rather than a literal string of N's.
 
 2. Fixed the logic used when matching an extension with a bracketed
 expression, such as 2[5-7]6.
 
 3. Removed all areas of code that were executed when NOT_NOW was
 #defined. The code in these areas had the potential to crash, for
 one thing, and the actual intent of these blocks seemed counterproductive.
 
 4. Fixed many many coding guidelines problems I encountered while looking
 through the corresponding code.
 
 5. Added failure cases and warning messages for when duplicate extensions
 are encountered.
 
 6. Miscellaneous fixes to incorrect or redundant statements.
 
 (closes issue ASTERISK-13704)
 Reported by: steinwej
 Tested by: mmichelson
 
 Review: http://reviewboard.digium.com/r/194/
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=188904