Skip to content

Allow gds__free after default pool cleanup - #9203

Open
dand-oss wants to merge 1 commit into
FirebirdSQL:masterfrom
dand-oss:fix/shutdown-free-guard
Open

dand-oss wants to merge 1 commit into
FirebirdSQL:masterfrom
dand-oss:fix/shutdown-free-guard

Conversation

@dand-oss

@dand-oss dand-oss commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

gds__free() can be reached after the default memory pool has been cleaned up during process exit. Dereferencing the pool at that point crashes release builds. A guard through getDefaultMemoryPool() is insufficient in debug builds because that helper asserts that the default pool still exists; the assertion logging path itself re-enters pool-dependent code after cleanup.

Check MemoryPool::defaultMemoryManager directly and skip the deallocation when the default pool is gone. The block is intentionally left to the operating system at that stage, and gds__free continues to return zero.

Independently reproduced on Linux x86-64 against the ASan/UBSan debug Firebird 5 client built with USE_SYSTEM_MALLOC=ON. A focused test compiled the actual production src/yvalve/gds.cpp, linked it with the other production client objects, called MemoryPool::cleanupDefaultPool(), then called gds__free(NULL) and exited immediately:

  • Original code: ASan DEADLYSIGNAL/stack overflow through the debug pool assertion and logging path.
  • Guard using getDefaultMemoryPool(): same failure, confirming the helper assertion defeats the null check.
  • Direct default-pool check: exits 0 and prints PASS: late gds__free returned.

The patched current-master gds.cpp also passes GCC 16.2 C++20 syntax compilation and git diff --check. This is a focused late-cleanup reproduction, not an end-to-end WinGLUE shutdown run.

Check the default pool pointer directly in gds__free. getDefaultMemoryPool() asserts that the pool still exists, so the previous null check did not protect the late process-exit path in debug builds.
@dand-oss dand-oss changed the title Guard gds__free when the default memory pool is unavailable Allow gds__free after default pool cleanup Oct 7, 2026
@dand-oss
dand-oss marked this pull request as ready for review October 7, 2026 10:10
@dand-oss
dand-oss force-pushed the fix/shutdown-free-guard branch from 8e001cb to 350e5d7 Compare October 7, 2026 10:10
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.

1 participant