[Asterisk-code-review] app chanspy: Fix occasional deadlock with ChanSpy and Local ... (asterisk[11])

Richard Mudgett asteriskteam at digium.com
Fri Mar 11 10:50:56 CST 2016


Richard Mudgett has posted comments on this change.

Change subject: app_chanspy: Fix occasional deadlock with ChanSpy and Local channels.
......................................................................


Patch Set 1: Code-Review-1

(3 comments)

Gads.  autochans seem inherently unsafe because any use of the chan pointer inside it could result in a corrupted or stale pointer.  And as you have stated, even the locking fix here isn't theoretically safe.

https://gerrit.asterisk.org/#/c/2374/1/include/asterisk/autochan.h
File include/asterisk/autochan.h:

Line 76: 	} while(0);
Do not put statement ending semicolons in the macro.

What if someone coded this:

if (boolean)
  ast_autochan_channel_lock(chan);
else
  ast_autochan_channel_lock(peer);

You would get a strange compiler error about the else even though it looks correct.

Or what if someone coded this:

for (ast_autochan_channel_lock(chan); boolean; increment)
   statement;

You would get another strange compiler error.


Line 79: 	ast_channel_unlock(autochan->chan);
Do not put statement ending semicolons in the macro.


https://gerrit.asterisk.org/#/c/2374/1/main/autochan.c
File main/autochan.c:

Line 54: 	ast_channel_lock(autochan->chan); /* autochan was still private, no need for ast_autochan_channel_lock() */
s/was/is/


-- 
To view, visit https://gerrit.asterisk.org/2374
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I293ae0014e531cd0e675c3f02d1d118a98683def
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 11
Gerrit-Owner: Walter Doekes <walter+asterisk at wjd.nu>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-HasComments: Yes



More information about the asterisk-code-review mailing list