<div dir="ltr">Hi Devs,<br><br>Regarding to issue #3834 our problem is caused by maintaining a reference to the renderer vtable in symbolObj and when the renderer is destroyed first, then calling symbolObj->vtable->freeSymbol leads to a crash.<br><div><br></div><div>I've already prepared a patch to use outputFormatObj instead of rendererVTableObj which is reference counted and hence it prevents from the renderer vtable to be destroyed until the symbol is alive.<br><br>However it looks more straightforward for me to rely on the already existing renderer_free_func of symbolObj which can contain the pointer to the renderer specific cleanup code. In this regard we can call  symbolObj->renderer_free_func instead of  symbolObj->renderer->freeSymbol and it appears to be safe assuming that renderer_free_func can be called even if render->cleanup is called previously.<div><br></div><div>We tested this approach and it seems to fix issue #3834. See the changes at:  </div><div><br></div><div><a href="https://github.com/szekerest/mapserver/commit/6a67c37d9c81569a655f7c21fbd48d6123457601">https://github.com/szekerest/mapserver/commit/6a67c37d9c81569a655f7c21fbd48d6123457601</a><br><br><br>Can this fix be applied or anyone can foresee issues with that?<br><br>Best regards,<br><br>Tamas<div><br></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div><div><span style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.800000190734863px"><br></span></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-08-24 18:27 GMT+02:00 Tamas Szekeres <span dir="ltr"><<a href="mailto:szekerest@gmail.com" target="_blank">szekerest@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">No comments so far.<div><br><div>I've prepared a fix to show what I've meant by storing the outputformat instead of the renderer vtable in symbolObj.<div><br></div><div><a href="https://github.com/szekerest/mapserver/commit/f4a4a2831a3d6228181938c0761fa5caf06c6452" target="_blank">https://github.com/szekerest/mapserver/commit/f4a4a2831a3d6228181938c0761fa5caf06c6452</a><br>
</div><div><br></div><div>Let me know if such change can be applied in master.</div><div><br></div><div>This change also contains a fix for the memory leaks caused by the embedded scalebar and legend symbols which is necessary for making the refcount approach to work properly.</div>
<div><br></div><div>We might also utilize MS_REFCNT macros for the outputformat refcount handling too (which are not yet used), but that would involve further changes to be made in further files.</div><div><br></div><div>
Best regards,</div><div><br></div><div>Tamas</div><div><div class="h5"><div><br></div><div><br></div><div><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-08-20 17:42 GMT+02:00 Tamas Szekeres <span dir="ltr"><<a href="mailto:szekerest@gmail.com" target="_blank">szekerest@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Devs,<div><br></div><div>Regarding to <a href="https://github.com/mapserver/mapserver/issues/3834" target="_blank">#3834</a>, I can see several hacks in the code attempting to fix the issue, but it seems we are still running into the same issue by getting a crash in msFreeSymbol at the line:</div>

<div><br></div><div>s->renderer->freeSymbol(s);<br></div><div><br></div><div>We've already been discussing about implementing a symbol cache at the renderers (and eliminate the need of maintaining back references to the renderer at symbolObj), however that seems to require fair amount of coding and testing at the first sight.</div>

<div><br></div><div>What if we change the renderer reference in symbolObj from rendererVTableObj to outputFormatObj (which contains the vtable)? Since the outputformat is reference counted we could make sure the outputformat (and the vtable) exists until the corresponding symbolObj is alive?</div>

<div><br></div><div><br></div><div>Best regards,</div><div><br></div><div>Tamas </div></div>
</blockquote></div><br></div></div></div></div></div></div></div>
</blockquote></div><br></div>