<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/3209/">https://reviewboard.asterisk.org/r/3209/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On February 12th, 2014, 6:12 p.m. EST, <b>Mark Michelson</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I'm not a fan of this patch for two reasons:
1) We're preventing a crash by introducing a memory leak.
2) The condition of undestroyed channels doesn't seem like enough to guarantee that the interfaces container is not currently being referenced
A more graceful fix is to replace the interfaces ao2_container in format.c with an ao2 global object. This way, each time a piece of code attempts to get the container, they will need to get a reference using ao2_global_obj_ref() (and check the function for a NULL return). This protects access to the container and guarantees that the container will not be freed as long as someone may be trying to use it.</pre>
</blockquote>
</blockquote>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I don't agree with #1, since this patch really only applies to SHUTDOWN_FAST (signal INT, TERM or HUP). It might rarely apply to SHUTDOWN_NORMAL (core stop now). Both of these modes skip shutdown of all modules, and SHUTDOWN_FAST doesn't even hangup active channels. Anyone testing for memory leaks would use 'core stop gracefully'.
You're probaby right about #2. This patch makes it far less likely for the issue to happen, but in theory still possible. Maybe it would be better to backport ast_register_cleanup, use that to register format_attr_shutdown?
I had considered using an ao2_global_obj_ref, but that would add overhead to the already expensive interfaces container lookups. Since the lookup is done multiple times per frame, I don't think more overhead is worth preventing a memory leak during SHUTDOWN_FAST.</pre>
<br />
<p>- Corey</p>
<br />
<p>On February 11th, 2014, 2:37 p.m. EST, Scott Griepentrog wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers, Corey Farrell and n8ideas.</div>
<div>By Scott Griepentrog.</div>
<p style="color: grey;"><i>Updated Feb. 11, 2014, 2:37 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-23103">ASTERISK-23103</a>
</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This fixes a possible crash on shutdown by preventing ao2_unref of interfaces while channels are active.
Patch by cfarrell
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/11/main/format.c <span style="color: grey">(407957)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/3209/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>