<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 18, 2024 at 8:32 PM Fox, Shawn D (US) via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-8187088204037686387">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="m_-8187088204037686387WordSection1">
<p class="MsoNormal">In our case we have a singleton class that acts as a façade and all of our calls to GDAL Apis are done by the methods of this class. The rest of our code base only interacts with the singleton so that we only have one project that actually
depends directly on the GDAL library. Since the _instance member is a static smart pointer the destructor of our class and the GDALDestroy function is being called after the main function exits.</p></div></div></div></blockquote><div><br></div><div>This is not a great plan unless you understand exactly the order of things being destroyed, which is not well-defined between compilation units unless you have done things to guarantee it. It seems likely that GDALDestroy() is attempting to free things already destroyed during program tear-down. Since your program is exiting, I can't imagine you need to call GDALDestroy() at all. You could also eliminate this issue by instantiating your GDAL class-thingee as the first line of your program rather than as a static.</div><div><br></div></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div></div>