[llvm] [clang] Avoid sandbox violation in Windows signal handler (PR #190615)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 7 12:22:17 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Jan Svoboda (jansvoboda11)

<details>
<summary>Changes</summary>

This bypasses the IO sandbox in some of Windows signal handling, which previously prevented stack traces from being printed.

---
Full diff: https://github.com/llvm/llvm-project/pull/190615.diff


1 Files Affected:

- (modified) llvm/lib/Support/Windows/Signals.inc (+7) 


``````````diff
diff --git a/llvm/lib/Support/Windows/Signals.inc b/llvm/lib/Support/Windows/Signals.inc
index 7e6799befb983..ec55af04c9c24 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -21,6 +21,7 @@
 #include <stdio.h>
 
 #include "llvm/Support/Format.h"
+#include "llvm/Support/IOSandbox.h"
 #include "llvm/Support/raw_ostream.h"
 
 // The Windows.h header must be after LLVM and standard headers.
@@ -798,6 +799,9 @@ void sys::CleanupOnSignal(uintptr_t Context) {
 }
 
 static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) {
+  // Let's not interfere with stack trace symbolication and friends.
+  auto BypassSandbox = sys::sandbox::scopedDisable();
+
   Cleanup(true);
 
   // Write out the exception code.
@@ -833,6 +837,9 @@ static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) {
 }
 
 static BOOL WINAPI LLVMConsoleCtrlHandler(DWORD dwCtrlType) {
+  // Let's not interfere with stack trace symbolication and friends.
+  auto BypassSandbox = sys::sandbox::scopedDisable();
+
   // We are running in our very own thread, courtesy of Windows.
   EnterCriticalSection(&CriticalSection);
   // This function is only ever called when a CTRL-C or similar control signal

``````````

</details>


https://github.com/llvm/llvm-project/pull/190615


More information about the llvm-commits mailing list