Issue |
157193
|
Summary |
Crash after error about SSE2 register return with SSE2 disabled
|
Labels |
new issue
|
Assignees |
|
Reporter |
geofft
|
Obviously this code does not compile but it should not crash I think. This is with latest nightly from apt.llvm.org on Ubuntu 24.04.
```c
__attribute__((target("no-sse2")))
double x(double y) {
return (long)y;
}
```
```
ubuntu@ip-172-16-0-59:/tmp$ clang-21 -c round.c -O3 -march=x86-64-v2
round.c:2:8: error: SSE2 register return with SSE2 disabled
2 | double x(double y) {
| ^
fatal error: error in backend: Access past stack top!
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: clang-21 -c round.c -O3 -march=x86-64-v2
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'round.c'.
4. Running pass 'X86 FP Stackifier' on function '@x'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 libLLVM.so.21.1 0x00007459bcbd366f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 63
1 libLLVM.so.21.1 0x00007459bcbd0f27 llvm::sys::RunSignalHandlers() + 135
2 libLLVM.so.21.1 0x00007459bcb0a903
3 libLLVM.so.21.1 0x00007459bcb0a8b2
4 libLLVM.so.21.1 0x00007459bcbcd800 llvm::sys::Process::Exit(int, bool) + 48
5 clang-21 0x00005d2dc51955cb
6 libLLVM.so.21.1 0x00007459bcb1d436 llvm::report_fatal_error(llvm::Twine const&, bool) + 278
7 libLLVM.so.21.1 0x00007459bcb1d31d
8 libLLVM.so.21.1 0x00007459bffe4e84
9 libLLVM.so.21.1 0x00007459bffe2936
10 libLLVM.so.21.1 0x00007459bffe1f1c
11 libLLVM.so.21.1 0x00007459bd0130e9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 713
12 libLLVM.so.21.1 0x00007459bcd44dff llvm::FPPassManager::runOnFunction(llvm::Function&) + 687
13 libLLVM.so.21.1 0x00007459bcd4ac2d llvm::FPPassManager::runOnModule(llvm::Module&) + 61
14 libLLVM.so.21.1 0x00007459bcd4555d llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1101
15 libclang-cpp.so.21.1 0x00007459c62ec9f3 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) + 7427
16 libclang-cpp.so.21.1 0x00007459c65e8576 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1558
17 libclang-cpp.so.21.1 0x00007459c517c5c9 clang::ParseAST(clang::Sema&, bool, bool) + 617
18 libclang-cpp.so.21.1 0x00007459c6de1b22 clang::FrontendAction::Execute() + 50
19 libclang-cpp.so.21.1 0x00007459c6d58694 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 948
20 libclang-cpp.so.21.1 0x00007459c6e6955c clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 700
21 clang-21 0x00005d2dc5194fab cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 5995
22 clang-21 0x00005d2dc5191cb4
23 libclang-cpp.so.21.1 0x00007459c6a1d4c2
24 libLLVM.so.21.1 0x00007459bcb0a887 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 151
25 libclang-cpp.so.21.1 0x00007459c6a1cd16 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const + 406
26 libclang-cpp.so.21.1 0x00007459c69e0272 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 546
27 libclang-cpp.so.21.1 0x00007459c69e045f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 159
28 libclang-cpp.so.21.1 0x00007459c69febb6 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 406
29 clang-21 0x00005d2dc5191789 clang_main(int, char**, llvm::ToolContext const&) + 6297
30 clang-21 0x00005d2dc519f1f3 main + 131
31 libc.so.6 0x00007459bb82a1ca
32 libc.so.6 0x00007459bb82a28b __libc_start_main + 139
33 clang-21 0x00005d2dc518f9b5 _start + 37
clang-21: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Ubuntu clang version 21.1.0 (++20250811123159+6f5c887e557f-1~exp1~20250811123320.21)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
```
You get the same failure with just `clang-21 -c round.c`. It gives the same _error_ but it does not _crash_ if I change the function to do `no-sse` instead of `no-sse2`.
<details><summary>Preprocessed source and run script (not very interesting):</summary>
```c
# 1 "<built-in>"
# 1 "round.c"
__attribute__((target("no-sse2")))
double x(double y) {
return (long)y;
}
```
```sh
# Crash reproducer for Ubuntu clang version 21.1.0 (++20250811123159+6f5c887e557f-1~exp1~20250811123320.21)
# Driver args: "-c" "round.c" "-O3" "-march=x86-64-v2"
# Original command: "/usr/lib/llvm-21/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-O3" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "round.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64-v2" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp" "-fcoverage-compilation-dir=/tmp" "-resource-dir" "/usr/lib/llvm-21/lib/clang/21" "-internal-isystem" "/usr/lib/llvm-21/lib/clang/21/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-ferror-limit" "19" "-fmessage-length=153" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "round.o" "-x" "c" "round.c"
"/usr/lib/llvm-21/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-O3" "-emit-obj" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "round.c" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=none" "-fmath-errno" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "x86-64-v2" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/tmp" "-fcoverage-compilation-dir=/tmp" "-ferror-limit" "19" "-fmessage-length=153" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-vectorize-loops" "-vectorize-slp" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-x" "c" "round-5e9079.c"
```
I see a couple of related issues/crashes from this type of thing but none look exactly the same at a quick glance. #87656 and #29774 seem most closely related though.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs