[Home]

Summary:ASTERISK-30258: Dialing API: Cancel a running async thread, does not always cancel all calls
Reporter:Frederic LE FOLL (flefoll)Labels:
Date Opened:2022-10-06 11:28:56Date Closed:2022-10-26 11:21:34
Priority:MinorRegression?
Status:Closed/CompleteComponents:Core/Dial
Versions:18.6.0 Frequency of
Occurrence
Occasional
Related
Issues:
Environment:Attachments:
Description:A race condition may occur in ast_dial_join() function (Dialing API: Cancel async thread), if caller cancels its call while a called party has just answered but has not yet started running its application.

This was detected with Page() application, calling approx 20 called parties with auto-answer, and caller almost immediately canceling its call (e.g. within 10 to 50 milliseconds).

Called party that has answered just before caller hangup:
- has not yet the is_running_app flag up, thus ast_dial_join() does not do Soft Hangup,
- but has left the waitfor loop, thus pthread_kill() does not have the expected effect.
Observation: when this race condition occurs for Page application, then :
- called parties (with one ast_dial_run() per called party) do not get cancelled, they start executing the application (ConfBridge for Page) and never get kicked out, because caller never got connected to ConfBridge,
- caller Channel gets stuck in ast_dial_join() because pthread_join(thread, NULL) never ends, except if all called devices hangup.

This was seen with Asterisk 18.6 but it should be reproductible with other versions, since ast_dial_join() has not changed in recent versions.
Comments:By: Asterisk Team (asteriskteam) 2022-10-06 11:29:01.818-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. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

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].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Frederic LE FOLL (flefoll) 2022-10-06 11:32:32.920-0500

I propose to submit a patch that adds soft hangups in ast_dial_join() when called parties are not yet running the application. The solution seems to work but needs confirmation.

By: Joshua C. Colp (jcolp) 2022-10-06 11:37:07.399-0500

Assigning pending patch.

By: Friendly Automation (friendly-automation) 2022-10-26 11:21:35.227-0500

Change 19487 merged by Friendly Automation:
Dialing API: Cancel a running async thread, may not cancel all calls

[https://gerrit.asterisk.org/c/asterisk/+/19487|https://gerrit.asterisk.org/c/asterisk/+/19487]

By: Friendly Automation (friendly-automation) 2022-10-26 11:51:46.541-0500

Change 19489 merged by Friendly Automation:
Dialing API: Cancel a running async thread, may not cancel all calls

[https://gerrit.asterisk.org/c/asterisk/+/19489|https://gerrit.asterisk.org/c/asterisk/+/19489]

By: Friendly Automation (friendly-automation) 2022-10-27 07:51:51.481-0500

Change 19409 merged by George Joseph:
Dialing API: Cancel a running async thread, may not cancel all calls

[https://gerrit.asterisk.org/c/asterisk/+/19409|https://gerrit.asterisk.org/c/asterisk/+/19409]

By: Friendly Automation (friendly-automation) 2022-10-27 07:52:15.275-0500

Change 19488 merged by George Joseph:
Dialing API: Cancel a running async thread, may not cancel all calls

[https://gerrit.asterisk.org/c/asterisk/+/19488|https://gerrit.asterisk.org/c/asterisk/+/19488]