<html>#2764: PUGH tries to free memory not allocated by malloc
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Roland Haas</td></tr>
<tr><td style='text-align:right'>   Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'>  Version:</td><td></td></tr>
<tr><td style='text-align:right'>     Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>major</td></tr>
<tr><td style='text-align:right'>Component:</td><td></td></tr>
</table>

<p>Compiling PUGH I get warnings:</p>
<div class="codehilite"><pre><span></span><span>In function ‘PUGH_SetupPGExtrasMemory’,</span>
<span>    inlined from ‘PUGH_SetupPGExtras’ at /data/rhaas/postdoc/gr/cactus/ET_trunk/configs/sim/build/PUGH/SetupPGV.c:101:11:</span>
<span>/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/sim/build/PUGH/SetupPGV.c:648:9: warning: ‘free’ called on pointer ‘this’ with nonzero offset 136 [-Wfree-nonheap-object]</span>
<span>  648 |         free(this->overlap);</span>
<span>      |         ^~~~~~~~~~~~~~~~~~~</span>
<span>/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/sim/build/PUGH/SetupPGV.c: In function ‘PUGH_SetupPGExtras’:</span>
<span>/data/rhaas/postdoc/gr/cactus/ET_trunk/configs/sim/build/PUGH/SetupPGV.c:96:10: note: returned from ‘malloc’</span>
<span>   96 |   this = malloc(sizeof(pGExtras));</span>
<span>      |</span>
</pre></div>


<p>which are correct since <code>overlap</code> is not actually from <code>malloc</code> (and neither are <code>ownvership</code> and <code>ghosts</code>). </p>
<p>The whole erro handling in <code>SetupPGV.c</code> is broken though, it e.g. assumes that <code>malloc</code> returns memory that is <code>NULL</code> initialized.</p>
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2764/pugh-tries-to-free-memory-not-allocated-by'>https://bitbucket.org/einsteintoolkit/tickets/issues/2764/pugh-tries-to-free-memory-not-allocated-by</a></p>
</html>