Skip to content

fix(sedona-gdal): skip GDALClose during interpreter shutdown - #1135

Merged
james-willis merged 1 commit into
apache:mainfrom
james-willis:jw/win-gdal-teardown-fix
Aug 10, 2026
Merged

fix(sedona-gdal): skip GDALClose during interpreter shutdown#1135
james-willis merged 1 commit into
apache:mainfrom
james-willis:jw/win-gdal-teardown-fix

Conversation

@james-willis

@james-willis james-willis commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The Windows wheel job passes every test, then aborts at process exit with 0xC0000409. Root cause: thread-local GDAL dataset caches (Rc<Dataset>) run GDALClose from their destructors while GDAL's shared library is being unloaded, which corrupts teardown on Windows. A Python atexit callback now latches a shutdown flag; Dataset::drop then leaves the handle open (harmless — the OS reclaims it at process exit).

Localized and validated with a subprocess probe on cp313: raster_only went 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 🥳

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).
@github-actions
github-actions Bot requested a review from zhangfengcdt August 7, 2026 23:55
@james-willis
james-willis requested review from paleolimbot and removed request for zhangfengcdt August 8, 2026 00:11

@paleolimbot paleolimbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

@james-willis
james-willis marked this pull request as ready for review August 10, 2026 18:10
@james-willis
james-willis merged commit 4f844cf into apache:main Aug 10, 2026
18 checks passed
@james-willis
james-willis deleted the jw/win-gdal-teardown-fix branch August 10, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants