[Home]

Summary:ASTERISK-29821: Deadlock in bridge_channel_internal_join() on local channels.
Reporter:Krzysztof Trempala (krzysztoft)Labels:patch
Date Opened:2021-12-27 03:20:13.000-0600Date Closed:2022-01-05 07:06:12.000-0600
Priority:MinorRegression?Yes
Status:Closed/CompleteComponents:Core/Bridging
Versions:18.9.0 Frequency of
Occurrence
Frequent
Related
Issues:
is caused byASTERISK-29748 bridging: Infinite loop when both Local channel halves in same bridge
is duplicated byASTERISK-29893 deadlock during bridge
is duplicated byASTERISK-30157 chan_iax2: Deadlock with device state and channel locking
Environment:Ubuntu 20.04Attachments:( 0) ASTERISK-29821.diff
Description:We've had a couple instances of a deadlocks. Deadlocks in function bridge_channel_internal_join() on local channels.
{noformat}
[Thread_1]                                          [Thread_2]
    |                                                   |
bridge_channel_internal_join(bridge_channel1)           |
  ..                                                    |
  ast_bridge_lock(bridge_channel1->bridge1);            |
  bridge_channel1->chan <= "local_chan;1"               |
  ast_channel_lock(bridge_channel1->chan);              |
  peer = ast_local_get_peer(bridge_channel1->chan);     |
  peer <= "local_chan;2"                                |
    |                                                   |
    |                                               bridge_channel_internal_join(bridge_channel2)
    |                                                 ..  
    |                                                 ast_bridge_lock(bridge_channe2->bridge2);
    |                                                 bridge_channel2->chan <= "local_chan;2"
    |                                                 ast_channel_lock(bridge_channel2->chan);
    |                                                 peer = ast_local_get_peer(bridge_channel2->chan);
    |                                                 peer <= "chan_local;1"
    |                                                  ..
    |                                                 ast_channel_lock(peer);  <== wait for lock on "chan_local;1"
    |
    |
  ast_channel_lock(peer);  <== wait for lock "local_chan;2" <== DEADLOCK
{noformat}
Comments:By: Asterisk Team (asteriskteam) 2021-12-27 03:20:13.966-0600

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: Joshua C. Colp (jcolp) 2021-12-27 04:52:32.666-0600

Please try this attached patch.

By: Krzysztof Trempala (krzysztoft) 2021-12-27 05:40:12.432-0600

Patch is OK. No deadlocks in the 30 minute test.

By: Matthias Hensler (cubbi) 2021-12-28 04:05:03.282-0600

Just to chime in here. When updating from 18.8.0 to 18.9.0 we ran into a deadlock too after only some hours of usage. Since I hadn't any sensible debug output at the time I rolled back to 18.8.0 and had no issues since then.

I suspect that our deadlock was the same problem and looking forward to have above patch included into 18.10.0 (not sure if I can give a shot before that unfortunately, as I have to wait until holidays are over here).

By: Friendly Automation (friendly-automation) 2022-01-05 07:06:13.514-0600

Change 17743 merged by Joshua Colp:
bridge: Unlock channel during Local peer check.

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

By: Friendly Automation (friendly-automation) 2022-01-05 07:09:09.992-0600

Change 17741 merged by Friendly Automation:
bridge: Unlock channel during Local peer check.

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

By: Friendly Automation (friendly-automation) 2022-01-05 07:10:56.286-0600

Change 17742 merged by Friendly Automation:
bridge: Unlock channel during Local peer check.

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

By: Friendly Automation (friendly-automation) 2022-01-05 07:12:08.862-0600

Change 17715 merged by Friendly Automation:
bridge: Unlock channel during Local peer check.

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

By: Friendly Automation (friendly-automation) 2022-01-13 13:12:35.558-0600

Change 17852 merged by Joshua Colp:
bridge: Unlock channel during Local peer check.

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