llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[Clang][Windows][Regression:22] "fatal error: error in backend: IO sandbox violation" on assertion failure, with no stacktrace printed

Open MagentaTreehouse opened this issue 8 months ago • 5 comments

Since https://github.com/llvm/llvm-project/commit/3911c6a2535736a365dd28163dd18daaa4398f74 @jansvoboda11 , clang-cl would not print a stack trace on assertion failure.

Example from #161002:

template <class... Ts>
auto f{[] (auto... a0) {
    return [=] (Ts... a1) {
        (..., [a0Cap{a0}, a1] { return a0Cap + a1; });
    };
}};

auto g{f<int>};

Command:

clang-cl.exe d:\dev\CppExamples\test2.cpp -std:c++20

Output:

Assertion failed: ArgPackSubstIndex && "found declaration pack but not pack expanding", file D:/dev/source/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp, line 6939
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: D:\\dev\\build\\llvm\\Clang-cl_22-RelWithDebInfo\\bin\\clang-cl.exe -cc1 -triple x86_64-pc-windows-msvc19.50.35728 -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name test2.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -fms-volatile -funwind-tables=2 -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -tune-cpu generic -D_MT -flto-visibility-public-std --dependent-lib=libcmt --dependent-lib=oldnames -stack-protector 2 -fdiagnostics-format msvc -fdebug-compilation-dir=D:\\dev\\CppExamples -fcoverage-compilation-dir=D:\\dev\\CppExamples -resource-dir D:\\dev\\build\\llvm\\Clang-cl_22-RelWithDebInfo\\lib\\clang\\23 -internal-isystem D:\\dev\\build\\llvm\\Clang-cl_22-RelWithDebInfo\\lib\\clang\\23\\include -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\ATLMFC\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Auxiliary\\VS\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.26100.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\shared" 
-internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\cppwinrt" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\18\\BuildTools\\VC\\Tools\\MSVC\\14.50.35717\\ATLMFC\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft 
Visual Studio\\18\\BuildTools\\VC\\Auxiliary\\VS\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.26100.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows 
Kits\\10\\\\include\\10.0.26100.0\\\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\winrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.26100.0\\\\cppwinrt" -fdeprecated-macro -ferror-limit 19 -fmessage-length=101 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.50.35728 -std=c++20 -fno-implicit-modules -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -o C:\\Users\\TREEHO~1\\AppData\\Local\\Temp\\test2-0db348.obj -x c++ d:\\dev\\CppExamples\\test2.cpp
1.      d:\dev\CppExamples\test2.cpp:8:14: current parser token '}'
Exception Code: 0xC000001D
fatal error: error in backend: IO sandbox violation
clang-cl: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 23.0.0git ([email protected]:MagentaTreehouse/llvm-project.git ce1a9fd76640929fe340c5c5d1bb493ea09ca9bc)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\dev\build\llvm\Clang-cl_22-RelWithDebInfo\bin
Build config: +assertions
clang-cl: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-cl: note: diagnostic msg: C:\Users\TREEHO~1\AppData\Local\Temp\test2-d6e103.cpp
clang-cl: note: diagnostic msg: C:\Users\TREEHO~1\AppData\Local\Temp\test2-d6e103.sh
clang-cl: note: diagnostic msg:

********************

MagentaTreehouse avatar Apr 06 '26 05:04 MagentaTreehouse

Thanks for reporting this. I'll look into this as soon as possible.

jansvoboda11 avatar Apr 06 '26 15:04 jansvoboda11

I don't see the sandbox violation reproducing in pre-commit Windows CI: https://github.com/llvm/llvm-project/pull/190615 How are you building your Clang?

jansvoboda11 avatar Apr 06 '26 16:04 jansvoboda11

cmake version 4.3.1 ninja version 1.13.2 msvc version 19.50.35728

Build commands:

cmake -S D:/dev/llvm-project/llvm -B D:/dev/build/llvm-project/Clang-cl_22-RelWithDebInfo -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl

cmake --build D:/dev/build/llvm-project/Clang-cl_22-RelWithDebInfo -j -t clang

MagentaTreehouse avatar Apr 07 '26 10:04 MagentaTreehouse

Should be fixed by https://github.com/llvm/llvm-project/pull/190615.

jansvoboda11 avatar Apr 07 '26 22:04 jansvoboda11

FWIW I don't think this should be marked as regression in Clang 22, since LLVM_ENABLE_IO_SANDBOX is set to OFF by default for all build types in that release. You'd need to explicitly opt-in into sandboxing in your build to hit this, or have a stale build directory that didn't fully reconfigure and inherited the enablement for main or some more recent point in the repo.

jansvoboda11 avatar Apr 07 '26 22:04 jansvoboda11