<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/4049/">https://reviewboard.asterisk.org/r/4049/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On October 7th, 2014, 1:53 p.m. EDT, <b>opticron</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/4049/diff/1/?file=67846#file67846line819" style="color: black; font-weight: bold; text-decoration: underline;">/branches/1.8/res/res_fax.c</a>
<span style="font-weight: normal;">
(Diff revision 1)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static struct ast_fax_session *fax_session_new(struct ast_fax_session_details *details, struct ast_channel *chan, struct ast_fax_session *reserved, struct ast_fax_tech_token *token)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#b1ebb0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2"></font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "></pre></td>
<th bgcolor="#b1ebb0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">819</font></th>
<td bgcolor="#c5ffc4" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb"> </span><span class="tb"> </span><span class="n">ao2_unlink</span><span class="p">(</span><span class="n">faxregistry</span><span class="p">.</span><span class="n">container</span><span class="p">,</span> <span class="n">reserved</span><span class="p">);</span></pre></td>
</tr>
</tbody>
</table>
<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 can't seem to find where the reserved session is actually linked into the faxregistry container. Have you verified that everything is properly balanced in the ref logs with this patch?</pre>
</blockquote>
</blockquote>
<pre style="margin-left: 1em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Somehow a session is being created by fax_session_new and later passed to fax_session_new as a reserved session. This happened with tests/fax/sip/gateway_mix4. It looks like fax_gateway_new is being called with details->gateway_timeout == 0. Then fax_gateway_start is called, gateway->s is initialized via fax_session_new. fax_gateway_start is called again, causing gateway->s to be reinitialized via fax_session_new for the second time. I'm unsure why this is, I'm having a bit of trouble tracing the call path.
On another note for ref's being balanced, ao2_unlink(container, some_object_not_in_container) is more or less a no-op (expensive, but I'm not sure of another way to handle this).
The following is from a processed refs log from Asterisk 12 with the gateway_mix4 test:
==== Leaked Object 0x7f454c031cf8 history ====
[17779] res_fax.c:1048 fax_session_new: +1 - [**constructor**]
[17779] res_fax.c:1123 fax_session_new: +1 - [1]
[17779] res_fax_spandsp.c:792 spandsp_fax_gw_gen_alloc: +1 - [2]
[17779] res_fax.c:1034 fax_session_new: +1 - [3]
[17779] res_fax.c:1123 fax_session_new: +1 - [4]
[17779] res_fax.c:2718 fax_gateway_start: -1 - [5]
[17779] res_fax_spandsp.c:797 spandsp_fax_gw_gen_release: -1 - [4]
[17779] res_fax_spandsp.c:792 spandsp_fax_gw_gen_alloc: +1 - [3]
[17779] res_fax.c:2642 destroy_gateway: -1 - [4]
[17779] res_fax.c:2645 destroy_gateway: -1 - [3]
[17779] res_fax_spandsp.c:797 spandsp_fax_gw_gen_release: -1 - [2]
* destroy_gateway tells us we are definitely dealing with gateway->s. I've noticed that the gateway functionality is not in 1.8, so I'm removing that from the affected versions.</pre>
<br />
<p>- Corey</p>
<br />
<p>On October 5th, 2014, 11:10 p.m. EDT, Corey Farrell 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.</div>
<div>By Corey Farrell.</div>
<p style="color: grey;"><i>Updated Oct. 5, 2014, 11:10 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-24392">ASTERISK-24392</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;">Reserved fax gateway sessions are added to faxregistry.container, then added again when the session is 'really' created. It seems that when it is re-added it adds a second reference into the container due to the id being different. Removal of the original list entry is not successful. This prevents the session from ever being unallocated.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </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;">Verified this resolves the leak in 11 and 12.</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/1.8/res/res_fax.c <span style="color: grey">(424175)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/4049/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>