<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120637>120637</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang crashes on invalid program
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
beached
</td>
</tr>
</table>
<pre>
Clang trunk/19.1.0 crash on the following curse
https://gcc.godbolt.org/z/T1cjEdcE5
```cpp
#include <csetjmp>
static std::jmp_buf buff{};
static const auto x = [](auto&& b) { return setjmp(b); }(buff);
void foo(std::jmp_buf b, int s ) {
[[clang::musttail]] return std::longjmp(b, s );
}
int main( int argc, char** argv ) {
foo( buff, argc == 2 );
}
```
```
fatal error: error in backend: failed to perform tail call elimination on a call site marked musttail
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: /opt/compiler-explorer/clang-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++23 -O3 <source> -isystem/app/boost/include
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'X86 DAG->DAG Instruction Selection' on function '@_Z3fooP13__jmp_buf_tagi'
#0 0x0000000003a26c78 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a26c78)
#1 0x0000000003a24dc4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a24dc4)
#2 0x00000000039758f3 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39758f3)
#3 0x0000000003a1c7fe llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3a1c7fe)
#4 0x0000000000cfd2db LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
#5 0x000000000397f9c3 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x397f9c3)
#6 0x000000000397fb28 (/opt/compiler-explorer/clang-trunk/bin/clang+++0x397fb28)
#7 0x000000000263ad18 llvm::X86TargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x263ad18)
#8 0x0000000004c08101 llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4c08101)
#9 0x0000000004c09f8d llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4c09f8d)
#10 0x0000000004c29704 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4c29704)
#11 0x0000000004c42128 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4c42128)
#12 0x0000000004c55e17 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4c55e17)
#13 0x0000000004cd5b1c llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, true>, bool&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4cd5b1c)
#14 0x0000000004cd7044 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4cd7044)
#15 0x0000000004cd8c2f llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4cd8c2f)
#16 0x0000000004cc5161 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4cc5161)
#17 0x0000000002e40245 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x0000000003394c52 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3394c52)
#19 0x0000000003394ee1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3394ee1)
#20 0x0000000003396849 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3396849)
#21 0x0000000003cc587e clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, 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*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cc587e)
#22 0x000000000435e1fc clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x435e1fc)
#23 0x0000000006254e7c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6254e7c)
#24 0x000000000435e925 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x435e925)
#25 0x000000000462a561 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x462a561)
#26 0x00000000045aa5db clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45aa5db)
#27 0x0000000004714033 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4714033)
#28 0x0000000000cff4fa cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xcff4fa)
#29 0x0000000000cf7d4d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x00000000043a7899 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x00000000039757f3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x39757f3)
#32 0x00000000043a7ab9 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x000000000436e53d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x436e53d)
#34 0x000000000436f53d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x436f53d)
#35 0x00000000043791dc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x43791dc)
#36 0x0000000000cfc1a1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xcfc1a1)
#37 0x0000000000bc5024 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xbc5024)
#38 0x000076d5eda29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x000076d5eda29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x0000000000cf77e5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xcf77e5)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70
```
Merry Cursemas
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWktv4zgS_jXMhbAhUU8fcnDspKcH3eigkx0M9mJQVMlhhya9JJXH_voFSdl65NHZGc9iFzuYRiyKZH31sVhVLJEaw7cS4BxlFyhbn9HW3il9XgFld1CfVap-Pl8JKrfY6lbeI3IVL-bxPMJMU3OHlcT2DnCjhFCPXG4xa7UBFC3vrN0blCwRuULkasvYfKvqSgk7V3qLyNU_Ebm6jdmPy5pdZihaojwK_7P93j2ShEsm2howSlbMgP2x26Pk0r2KlsZSyxk2tnYSkuWP3X5TtQ2u2qZBxQUq1ii56PsxJY3FtLUKP2GUrHHQFZHStSGSI5LjCpEFRsUF1mBbLXEnkpTuBUousJuVlF6EbwhQHhSvcaMUIuVLOIisMJcWG9xNjqJlEH7BHKeh-6411lIuHKRsfZR_mE0ouT0iWYW5OvHFOoBwMnaUS0RKL4_qLXN92R3ViCwRWbqmhyEKjDvUgTSy8oMcO44gMhKCh-sTJA4fG2qpwKC10ihZhh-YS1xRdg_SaYEbygXU2Cq8B90ovcNOYcyoEBgE33FJLVfSmRMNrYZbwDuq76HGR4Ki5fWXy-XNJTZtteMWU1y1W6xhr7R1k0-Mjtu7tpoztUPkSoiHw5_ZXqsfwCwiV9yYFgwiV5jKGh8szll0MG-ngtWUgSNor2GvFQNjoMZGtTo0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