[asterisk-bugs] [Asterisk 0015987]: ao2_iterator_init() does not hold a reference to the container it is iterating
Asterisk Bug Tracker
noreply at bugs.digium.com
Mon Oct 5 20:19:47 CDT 2009
A NOTE has been added to this issue.
======================================================================
https://issues.asterisk.org/view.php?id=15987
======================================================================
Reported By: kpfleming
Assigned To: kpfleming
======================================================================
Project: Asterisk
Issue ID: 15987
Category: Core/General
Reproducibility: always
Severity: minor
Priority: normal
Status: assigned
Asterisk Version: Older 1.4
JIRA:
Regression: No
Reviewboard Link:
SVN Branch (only for SVN checkouts, not tarball releases): N/A
SVN Revision (number only!):
Request Review:
======================================================================
Date Submitted: 2009-09-29 11:03 CDT
Last Modified: 2009-10-05 20:19 CDT
======================================================================
Summary: ao2_iterator_init() does not hold a reference to the
container it is iterating
Description:
While researching the astobj2 code to add some new functionality, I
discovered that the ao2_iterator_init() function makes a copy of the
container pointer it is passed, but does not increase the reference count
on the container. In situations where dynamically allocated containers are
being used and pointers to them are passed to (and iterators create on them
by) other functions, this could lead to the container being destroyed while
there are still iterators open using it.
There are no current usages of astobj2 in the tree that could experience
this problem, as they do not use dynamically allocated containers with
short lifetimes (all existing container usage would outlive any iterators
that might be used on those containers), but the API is clearly not living
up to the 'automatic reference count management' that developers would
expect it to have.
======================================================================
----------------------------------------------------------------------
(0111890) svnbot (reporter) - 2009-10-05 20:19
https://issues.asterisk.org/view.php?id=15987#c111890
----------------------------------------------------------------------
Repository: asterisk
Revision: 222152
U branches/1.4/apps/app_queue.c
U branches/1.4/channels/chan_iax2.c
U branches/1.4/include/asterisk/astobj2.h
U branches/1.4/main/astobj2.c
U branches/1.4/res/res_musiconhold.c
------------------------------------------------------------------------
r222152 | kpfleming | 2009-10-05 20:19:46 -0500 (Mon, 05 Oct 2009) | 20
lines
Fix ao2_iterator API to hold references to containers being iterated.
See Mantis issue for details of what prompted this change.
Additional notes:
This patch changes the ao2_iterator API in two ways: F_AO2I_DONTLOCK
has become an enum instead of a macro, with a name that fits our
naming policy; also, it is now necessary to call
ao2_iterator_destroy() on any iterator that has been
created. Currently this only releases the reference to the container
being iterated, but in the future this could also release other
resources used by the iterator, if the iterator implementation changes
to use additional resources.
(closes issue https://issues.asterisk.org/view.php?id=15987)
Reported by: kpfleming
Review: https://reviewboard.asterisk.org/r/383/
------------------------------------------------------------------------
http://svn.digium.com/view/asterisk?view=rev&revision=222152
Issue History
Date Modified Username Field Change
======================================================================
2009-10-05 20:19 svnbot Checkin
2009-10-05 20:19 svnbot Note Added: 0111890
======================================================================
More information about the asterisk-bugs
mailing list