[asterisk-bugs] [Asterisk 0013765]: after return from child context ARG is cleared

Asterisk Bug Tracker noreply at bugs.digium.com
Fri Oct 24 14:57:31 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=13765 
====================================================================== 
Reported By:                pj
Assigned To:                murf
====================================================================== 
Project:                    Asterisk
Issue ID:                   13765
Category:                   PBX/pbx_ael
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
Asterisk Version:           SVN 
SVN Branch (only for SVN checkouts, not tarball releases):  trunk 
SVN Revision (number only!): 148373 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             2008-10-22 15:10 CDT
Last Modified:              2008-10-24 14:57 CDT
====================================================================== 
Summary:                    after return from child context ARG is cleared
Description: 
simple ael dialplan, that ilustrates situation:
after gosub to child and return back to parent context, ARG1 value is
cleared after return back to parent context.
tested svn trunk and svn branch 1.6.0 both have this issue.


context parent {
  s => {
        Verbose(In parent before gosub to child cx arg1 has value
${ARG1});
        Gosub(child,s,1(${ARG1}));
        Verbose(In parent after gosub to child cx arg1 has value
${ARG1});
        return;
  }
}

context child {
  s => {
        Verbose(In child arg1 has value ${ARG1});
        return;
  }
}

====================================================================== 

---------------------------------------------------------------------- 
 (0094247) murf (administrator) - 2008-10-24 14:57
 http://bugs.digium.com/view.php?id=13765#c94247 
---------------------------------------------------------------------- 
I've given this some thought; The fact that args are erased is an artifact
of
gosub processing. I don't think you can call this a bug -- all languages
have undocumented (gray) areas in their specs, and you do well not to 
use undocumented features, because they can change behavior at any time,
and you will not have anyone to blame but yourself.

If you are using AEL, do not use the Gosub app. Use the macro keyword and
constructs instead. Do NOT use temporary variables outside their normal
scope, nor depend on their current behavior outside that scope. In AEL,
never use $(ARGx}, neither in a macro or outside of one. That way, you can
take advantage of the upwards compatibility that AEL will provide.

Even if you are using extensions.conf, you should not play with or depend
on the value of ${ARGx} variables outside the Macro or Gosub context. The
behavior is undocumented, and guaranteed to change over time. It is bad
programming practice to play tricks with such items.

Treat ${ARGx} items as temporary in Gosubs/Macros, as well as named
arguments in AEL. Access only the ones passed.  To do otherwise would only
introduce
bugs as time goes on.

If you feel strongly that I'm missing some important point, let me know--
just reopen this and we'll work it out. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-10-24 14:57 murf           Note Added: 0094247                          
======================================================================




More information about the asterisk-bugs mailing list