Return Without Gosub: Stack Is Empty

Home » Asterisk Users » Return Without Gosub: Stack Is Empty
Asterisk Users 1 Comment

exten => s,1,NoOp(Dial)
 same => n,NoOp(FirstChannel: ${CHANNEL})
 same => n,Dial(????,60,gF)
 same => n,NoOp(SecondChannel: ${CHANNEL})
 same => n,Return()

exten => s,1,GoSub(sub-out-do-dial,s,1)

In case of the destination channel hangs up in log i see:
ERROR[26570][C-000000e7] app_stack.c: Return without Gosub: stack is empty

Yes. SecondChannel != FirstChannel. Is it a wrong way to use Dial(g)+Gosub? Or any Dial in sub?

One thought on - Return Without Gosub: Stack Is Empty

  • I think you mean if the calling channel hangs up you get the error message.

    The first channel (calling party) knows about being in the subroutine. It was the channel executing dialplan to get into the subroutine. Use of the g option with this dialplan is OK as the calling channel knows where the subroutine was called from.

    The second channel (called party) knows nothing about being in a subroutine so it cannot return from one. It has not executed any dialplan before. The F
    option simply tells it to start executing dialplan at the priority after the dial application. This dialplan needs to be able to distinguish between the two channels and act accordingly. Using the F() option with a dialplan location is the simplest way to distinguish between the two channels.