From 5469123a69d90fa11dc96ccb2b901dde11af8b83 Mon Sep 17 00:00:00 2001 From: "Schilling, Matthew" Date: Thu, 22 Oct 2026 07:32:24 -0700 Subject: [PATCH] fix: Don't free tracer context in DllMain during process termination Matches what's being done here: https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain `lpvReserved` is "non-NULL" when process is terminating and its not safe to call the tracer context destructor there. Signed-off-by: Schilling, Matthew --- source/layers/tracing/windows/tracing_init.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/layers/tracing/windows/tracing_init.cpp b/source/layers/tracing/windows/tracing_init.cpp index 3594a4cf..bcdf7d74 100644 --- a/source/layers/tracing/windows/tracing_init.cpp +++ b/source/layers/tracing/windows/tracing_init.cpp @@ -17,6 +17,9 @@ namespace tracing_layer { */ extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { if (fdwReason == DLL_PROCESS_DETACH) { + if (lpvReserved) { + return TRUE; + } delete pGlobalAPITracerContextImp; } else if (fdwReason == DLL_PROCESS_ATTACH) { pGlobalAPITracerContextImp = new APITracerContextImp;