fix(sedona-gdal): skip GDALClose during interpreter shutdown - #1135
Merged
Conversation
Closing a GDAL dataset while the GDAL shared library is being unloaded aborts the process on Windows (0xC0000409) at interpreter exit. A Python atexit callback now latches a shutdown flag; Dataset::drop then leaves the handle open (the OS reclaims it at process exit).
james-willis
requested review from
paleolimbot
and removed request for
zhangfengcdt
August 8, 2026 00:11
paleolimbot
approved these changes
Aug 8, 2026
paleolimbot
left a comment
Member
There was a problem hiding this comment.
This is great! We had some issues like this in pyarrow related to various C++ APIs with shutdown behaviour.
In addition to this, we should also strive to better scope the cache / maintain it a bit better so that it less frequently tries to scramble and delete a whole lot of datasets at once right at process close. I am skeptical of most non-connection scoped caches (we have a few here) because of issues like this. (Not a battle for this PR.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Windows wheel job passes every test, then aborts at process exit with
0xC0000409. Root cause: thread-local GDAL dataset caches (Rc<Dataset>) runGDALClosefrom their destructors while GDAL's shared library is being unloaded, which corrupts teardown on Windows. A Pythonatexitcallback now latches a shutdown flag;Dataset::dropthen leaves the handle open (harmless — the OS reclaims it at process exit).Localized and validated with a subprocess probe on cp313:
raster_onlywent from 10/10 crashes to 0/10 (and the full suite 12/12 → 0/12), with all 3217 tests still passing.This should make the wheels all green now 🥳