[asterisk-bugs] [JIRA] (ASTERISK-29129) pbx_lua: Dial subroutine leads to audio issues and FRACKs

Joshua C. Colp (JIRA) noreply at issues.asterisk.org
Sun Oct 18 04:42:36 CDT 2020


    [ https://issues.asterisk.org/jira/browse/ASTERISK-29129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=252481#comment-252481 ] 

Joshua C. Colp commented on ASTERISK-29129:
-------------------------------------------

The module you're having difficulty with is in 'extended' support status and is supported only by community members.  Your issue is in the queue. Your patience is appreciated as a community developer may work the issue when time and resources become available.

Asterisk is an open source project and community members work the issues on a voluntary basis. You are welcome to develop your own patches and submit them to the project.[1]

If you are not a programmer and you are in a hurry to see a patch provided then you might try rallying support on the Asterisk users mailing list or forums.[2] Another alternative is offering a bug bounty on the asterisk-dev mailing list.[3] Often a little incentive can go a long way.

[1]: https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process
[2]: http://www.asterisk.org/community/discuss
[3]: https://wiki.asterisk.org/wiki/display/AST/Asterisk+Bug+Bounties



> pbx_lua: Dial subroutine leads to audio issues and FRACKs
> ---------------------------------------------------------
>
>                 Key: ASTERISK-29129
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-29129
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: PBX/pbx_lua
>    Affects Versions: 17.7.0
>         Environment: Arch linux
>            Reporter: Daniil Gentili
>            Severity: Minor
>
> Consider the following simple lua dialplan:
> {noformat}
> extensions = {
>     ["from-internal"] = {
>         ["_."] = function(context, exten)
>             app.Answer()
>             app.Dial("Local/music at music", 100, "G(pony^999^1)")
>             app.Hangup()
>         end
>     },
>     ["pony"] = {
>         ["caller"] = function(context, exten)
>             app.Bridge(channel.DIALEDPEERNAME:get())
>         end,
>         ["callee"] = function(context, exten)
>             app.Answer()
>             os.execute("sleep 2")
>             app.Wait(5)
>             app.Congestion()
>             app.Hangup()
>         end
>     },
>     ["music"] = {
>         ["music"] = function(context, exten)
>             app.Answer()
>             app.Playback("/home/daniil/Musica/bruh")
>         end
>     }
> }
> {noformat}
> and conf dialplan:
> {noformat}
> [pony]
> exten => 999,1,GoTo(pony,caller,1)
> exten => 999,2,GoTo(pony,callee,1)
> {noformat}
> When executing the {{callee}} side of the {{G}} dial subroutine, if a big enough delay is introduced before calling {{Wait}}, once it is called it will cause audio issues and fracks.
> Dial() creates the following two bridges:
> * bridge A: SIP/XXXX <=> Local/pony at caller (A;1 <=> A;2)
> * bridge B: Local/pony at callee <=> Local/music at music (B;1 <=> B;2)
> Bridge(A;1, B;1) does the following:
> * B;1 is yanked out of the B channel, and put into the new C bridge:
> * bridge C: SIP/XXXX <=> Local/music at music (A;1 <=> B;1)
> Yanking the B;1 channel out is done internally by copying the channel struct members to a new channel and [hanging up the old zombie channel with the zombie flag+nullframe|https://github.com/asterisk/asterisk/blob/e831952ebac04042051538e444dfb917782b01c4/main/channel.c#L7187].
> Finally, the new channel structure is swapped into the currently running lua PBX by the [fixup function|https://github.com/asterisk/asterisk/blob/master/pbx/pbx_lua.c#L137].
> Race condition:
> * If the `Wait()` function gets called before `Bridge()`, it will be called on the old to-be-killed channel.
> The nullframe+zombie flag combination sent to the to-be-killed channel will be received correctly by `Wait()`, and will hangup the routine.
> * If the `Wait()` function gets called after `Bridge()`, it will be called on the newly swapped channel.
> The nullframe+zombieflag combo will be ignored, and instead `Wait()` will start sending null packets into the newly cloned channel (which is already in use by Playback in another context!), causing audio issues, and finally segfaults on hangup, probably when pbx_lua tries starting an autoservice on a hung up channel.
> Removing the lua fixup function solves the issue, but I'm not sure if this will introduce issues elsewhere.
> ASTERISK-17635, which is the issue that initially led to the introduction of the fixup function, seems to use a pre-masquerading version of asterisk; but the ast_channel_move (=> fixup) function seems to be used in places other than the bridging function.
> So I'm posting this here, in hopes of getting help for a fix that doesn't potentially break other stuff :)



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list