<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Le 18/09/2024 à 18:27, Fox, Shawn D
(US) via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:20240918162712.013BC6144EAD@lists.osgeo.org">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-ligatures:standardcontextual;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Could someone help me understand this
sentence from the documentation at
<a href="https://gdal.org/en/latest/api/raster_c_api.html"
moz-do-not-send="true">gdal.h: Raster C API — GDAL
documentation</a> for the GDALDestroy function?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">“Since GDAL 2.4.0, this function may be
called by application code, since it is no longer called
automatically, on non-MSVC builds, due to ordering problems
with respect to automatic destruction of global C++ objects.”<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">What are the ordering problems and why
might it be called due to ordering problems? The statement
does state some kind of difference between MSVC and non-MSVC
builds. The sentence doesn’t clearly state to me whether I
should or shouldn’t call that function to cleanup. The
language in the documentation is ambiguous, and it is not
clear to me how important it is to call this method. Cleaning
up seems like a good idea but I could simply free the memory
via delete for any object that is returned instead of calling
GDALDestroy. <br>
</p>
</div>
</blockquote>
<p>You don't necessarily have to call GDALDestroy(). It reclaims
various static objects allocated by GDAL. Basically it helps for
"valgrind --leak-check=full" use cases.</p>
<p>The issue that caused it to no longer be registered as a GCC
destructor function is that if you have for example a static
GDALDataset object, it was found that GDALDestroy() was called
before the destruction of the GDALDataset object, which lead to
double-free. Cf commit comment of
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/commit/e8c9bea5dbe8e90d01d575f94a040fcaee27c24f">https://github.com/OSGeo/gdal/commit/e8c9bea5dbe8e90d01d575f94a040fcaee27c24f</a><br>
</p>
<blockquote type="cite"
cite="mid:20240918162712.013BC6144EAD@lists.osgeo.org">
<div class="WordSection1">
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On a RHEL8 build, which is non-MSVC, I am
observing segmentation faults. The errors vary from one
execution of the program to another.
</p>
</div>
</blockquote>
<p>Hard to tell the reason. Show the code, use Valgrind.</p>
<p>Check also with ldd that your executable isn't linked to 2
different versions of libproj. The error message you mention is
typical of that situation<br>
</p>
<span style="white-space: pre-wrap">
</span>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>