You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows runtime: a DLL's copy leaves its crash handler installed after FreeLibrary #236
ct_maybe_install_backtrace calls SetUnhandledExceptionFilter(ct_exception_filter) at L101 and ignores the filter it replaces.
The copy in a DLL loaded after the executable thus replaces the executable's handler with its own, and nothing restores the previous one. When FreeLibrary unloads that DLL, its release (src/runtime/windows/ct_runtime_dbghelp.cpp L66-L96) closes its DbgHelp session but leaves the process's unhandled-exception filter pointing into the DLL's unmapped image. The next exception that nothing handles then calls into that address. Whatever has been mapped there since runs, or the call faults in unmapped memory, instead of a crash handler that prints a backtrace.
Found by reading the code during the review of #235 (for #225); not reproduced.
Expected
After FreeLibrary unloads a DLL whose copy installed the crash handler, an exception that nothing handles is reported either by a handler that is still loaded, such as the executable's, or by the system's default handling.
Possible directions
Install the crash handler from the executable's copy only.
Fixed by #241, merged on 2026-11-04 as 09df200: only the executable's copy of the runtime installs the crash handler. The copy in a DLL installs none and leaves the process's filter alone, so nothing is left behind when FreeLibrary unloads the DLL.
Validation, from #241, in the four Windows jobs of LLVM versions (LLVM 19, 20, 22, 23):
on main, 232/238 in each job: the tests of a crash reported after the DLL has unloaded fail, with no backtrace (run 41722488438);
with the fix, 238/238 in each job, and the 15 jobs of LLVM versions, Build and the other checks pass (run 41759624900).
One limit is accepted and documented in the README ("Crash handler on Windows"): a program that does not link the runtime gets no crash backtrace from an instrumented DLL. The fix is in the changelog of 0.13.0, which #269 prepares.
Activity
fix(runtime): find the copy above among the loaded modules
test(runtime): load the copies of the runtime library in a helper
test(runtime): check two DLLs unloaded around a host's filter
test(runtime): print the exception that the host's filter sees
test(runtime): check that the crash tests' DLLs unload
test(runtime): check which copy's handler prints the backtrace
refactor(runtime): share the readability check of the Windows runtime
fix(runtime): read a module's headers only once found readable
test(runtime): check a DLL unloading past unreadable module headers
fix(runtime): look through every module the loader lists
fix(runtime): hand the filter over to every copy that holds the handler
test(runtime): check two copies whose handlers replaced one handler
docs(readme): describe the crash handler of a DLL's copy
docs(changelog): note the crash handler left by an unloaded DLL
24 remaining items
test(runtime): check that a DLL's copy installs no crash handler
test(runtime): check the host's filter while a DLL is loaded
test(runtime): check an unload while another thread changes the filter
test(runtime): check that the host's last filter stays after an unload
test(runtime): describe the crash handler tests in the file's header
docs(readme): say that only the executable's copy installs the handler
docs(changelog): note that only the executable installs the handler
test(runtime): match a crash in a DLL with gtest's matchers alone
test(runtime): match a crash in a DLL with gtest's matchers alone
test(runtime): match a crash in a DLL with gtest's matchers alone
test(runtime): make the other thread's filter differ from the one set
test(runtime): make the other thread's filter differ from the one set
test(runtime): make the other thread's filter differ from the one set
SizzleUnrlsd commentedon Nov 16, 2026
Fixed by #241, merged on 2026-11-04 as 09df200: only the executable's copy of the runtime installs the crash handler. The copy in a DLL installs none and leaves the process's filter alone, so nothing is left behind when
FreeLibraryunloads the DLL.Validation, from #241, in the four Windows jobs of
LLVM versions(LLVM 19, 20, 22, 23):main, 232/238 in each job: the tests of a crash reported after the DLL has unloaded fail, with no backtrace (run 41722488438);LLVM versions,Buildand the other checks pass (run 41759624900).One limit is accepted and documented in the README ("Crash handler on Windows"): a program that does not link the runtime gets no crash backtrace from an instrumented DLL. The fix is in the changelog of 0.13.0, which #269 prepares.