Skip to content

release geodifflib on shutdown() for macOS - #261

Open
harminius wants to merge 1 commit into
masterfrom
fix/shutdown-for-unix-os
Open

release geodifflib on shutdown() for macOS#261
harminius wants to merge 1 commit into
masterfrom
fix/shutdown-for-unix-os

Conversation

@harminius

Copy link
Copy Markdown

Fixes MerginMaps/qgis-plugin#867 and maybe MerginMaps/qgis-plugin#866

Problem:
shutdown() previously only released the library on Windows; on Linux/macOS it just dropped the Python reference, so ctypes never called dlclose() and the image stayed mapped. On macOS the old and new copies of the library coexisted in the process resulting in QGIS to crash.

Solution:
This makes pygeodiff.shutdown() actually unload the library on macOS.

Limitation:
dlclose() is best-effort - on modern Linux (glibc ≥ 2.34) the library often stays mapped anyway. However, the bug doesn't appear on Linux because it re-dlopen() the lib by its name (SONAME). This means only one copy is ever loaded - unfortunately, the old one.
Also added a small guard so a failed load doesn't raise in __del__.

@harminius
harminius requested a review from wonder-sk August 28, 2026 10:52
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.

QGIS 3.44 macOS (Apple Silicon): crash on project download right after plugin (re)install (works after restart)

1 participant