Skip to content
This repository was archived by the owner on May 24, 2026. It is now read-only.

Commit bf30486

Browse files
caesayclaude
andcommitted
Pin DLL to prevent unload crash from libgsf DllMain
Use GetModuleHandleExW with GET_MODULE_HANDLE_EX_FLAG_PIN to prevent the DLL from being unloaded during process exit. This stops libgsf's DllMain(DETACH) from running and crashing when it tries to clean up GLib objects that are in an inconsistent state during termination. Also removes MsiCloseAllHandles from ProcessExit and removes the MsiHandle finalizer - the OS reclaims all memory on exit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8757bcf commit bf30486

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

msi-interop/handle_table.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,13 @@ __attribute__((constructor))
316316
static void
317317
handle_table_auto_init(void)
318318
{
319+
#ifdef _WIN32
320+
// Pin this DLL so it's never unloaded. Prevents libgsf's DllMain from
321+
// running during process exit, which crashes when GLib objects remain.
322+
HMODULE hSelf;
323+
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
324+
(LPCWSTR)handle_table_auto_init, &hSelf);
325+
#endif
319326
gsf_init();
320327
g_type_ensure(libmsi_database_get_type());
321328
g_type_ensure(libmsi_query_get_type());

0 commit comments

Comments
 (0)