[asterisk-dev] Unlocked access to channel in __ast_pbx_run() (was Re: Asterisk 1.4.19-rc1 Now Available)
Russell Bryant
russell at digium.com
Fri Mar 7 10:39:40 CST 2008
Michael Neuhauser wrote:
> I've did a test that confirms my suspicion that __ast_pbx_run() does not
> hold the lock of the channel and that this is a problem because channel
> values that are used in this function (context, exten, priority,
> _softhangup, ...) can change at any time, e.g., when a redirect is
> performed over AMI.
<snip>
> The async-goto was executed by the manager thread while the pbx-thread
> was between ast_exists_extension() and ast_spawn_extension()! I think
> this shows that just accessing c->context without
> lock(c)/make-private-copy/unlock(c) etc. is not OK in __ast_pbx_run().
> Any comments?
You are absolutely correct that accessing this data without the channel locked
is not safe. The code needs to be fixed to hold the channel lock when
appropriate, or alternatively, use a lock/private copy/unlock scheme to reduce
the amount of time the lock is held. That does mean that the data you copied
could change while you're still using your private copy, but in most cases that
is ok.
If you have a patch in mind, post it to bugs.digium.com. If not, open a bug
report on there, anyway, and someone will fix it up.
Thanks,
--
Russell Bryant
Senior Software Engineer
Open Source Team Lead
Digium, Inc.
More information about the asterisk-dev
mailing list