[llvm] [LLVM] Disable IO sandbox in collectAddressSymbols (PR #194597)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 04:23:15 PDT 2026
https://github.com/SLTozer created https://github.com/llvm/llvm-project/pull/194597
The function `collectAddressSymbols` is used by debugify to symbolize addresses captured in the current invocation of LLVM, which it does by executing llvm-symbolizer with temporary input and output files. Creating the temporary files has an explicit sandbox exclusion, as temporary files are necessarily not part of the compiler's formal output, but attempting to read back the output file via MemoryBuffer triggers a sandbox violation. Since we are always only operating on temporary files within collectAddressSymbols, this patch disables the IO sandbox in that function.
>From eadc452ceadeb0914486cdb59ac9f1d180305e84 Mon Sep 17 00:00:00 2001
From: Stephen Tozer <stephen.tozer at sony.com>
Date: Tue, 28 Apr 2026 12:10:31 +0100
Subject: [PATCH] [LLVM] Disable IO sandbox in collectAddressSymbols
The function `collectAddressSymbols` is used by debugify to symbolize
addresses captured in the current invocation of LLVM, which it does by
executing llvm-symbolizer with temporary input and output files. Creating
the temporary files has an explicit sandbox exclusion, as temporary files
are necessarily not part of the compiler's formal output, but attempting
to read back the output file via MemoryBuffer triggers a sandbox violation.
Since we are always only operating on temporary files within
collectAddressSymbols, this patch disables the IO sandbox in that function.
---
llvm/lib/Support/Signals.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/lib/Support/Signals.cpp b/llvm/lib/Support/Signals.cpp
index f160a135f623d..7936a715fb4f6 100644
--- a/llvm/lib/Support/Signals.cpp
+++ b/llvm/lib/Support/Signals.cpp
@@ -155,6 +155,10 @@ std::optional<SmallVector<std::pair<unsigned, std::string>, 0>>
collectAddressSymbols(void **AddressList, unsigned AddressCount,
const char *MainExecutableName,
const std::string &LLVMSymbolizerPath) {
+ // This function deals with temporary files for the purposes of symbolization
+ // only, not formal compiler output.
+ auto BypassSandbox = sys::sandbox::scopedDisable();
+
BumpPtrAllocator Allocator;
StringSaver StrPool(Allocator);
SmallVector<const char *, 0> Modules(AddressCount, nullptr);
More information about the llvm-commits
mailing list