[gdal-dev] Throwing exceptions in GDAL Error Handler

Simon Eves simon.eves at omnisci.com
Mon Dec 6 09:59:47 PST 2021


OK, thanks for confirming.

On Sat, Dec 4, 2021 at 3:59 PM Even Rouault <even.rouault at spatialys.com>
wrote:

> You shouldn't throw C++ exceptions, as this is a callback of the C API.
> This will cause all sort of issues, most of the time memory leaks, etc.
> Le 05/12/2021 à 00:49, Simon Eves a écrit :
>
> We have a custom Error Handler callback and for a while now it was
> configured to throw an exception if the class was Failure or higher.
>
> Unfortunately, we have found that this causes havoc with OpenEx() because
> the file management state is left bad (e.g. the anti-recursion stuff) and
> GDAL will believe the file is open when it isn't, and other such hilarity.
>
> We have changed this to disable and re-enable the exception throw (and
> just log the error) either side of an OpenEx() but I am concerned that
> there are perhaps other situations where throwing may cause similar issues.
>
> The docs for CPLSetErrorHandler() don't explicitly say anything about not
> throwing in the callback.
>
> Please advise.
>
> SE
>
> --
> <http://www.omnisci.com/>
> Simon Eves
> Senior Graphics Engineer, Rendering Group
> 100 Montgomery St (5th Floor), San Francisco, CA 94104, USA
>
>
> Email: simon.eves at omnisci.com | Cell:  +1 (415) 902-1996
>
>
> _______________________________________________
> gdal-dev mailing listgdal-dev at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/gdal-dev
>
> -- http://www.spatialys.com
> My software is free, but my time generally not.
>
>

-- 
<http://www.omnisci.com/>
Simon Eves
Senior Graphics Engineer, Rendering Group
100 Montgomery St (5th Floor), San Francisco, CA 94104, USA


Email: simon.eves at omnisci.com | Cell:  +1 (415) 902-1996
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211206/43fe2fe1/attachment.html>


More information about the gdal-dev mailing list