Issue 130513
Summary Clang crashes with segmentation fault when using `target_clones` attribute with redefined `int` and old-style function definition
Labels clang
Assignees
Reporter bi6c
    Compiler Explorer: [https://godbolt.org/z/eP57zqoPK](https://godbolt.org/z/eP57zqoPK)

(Found by fuzzer)

Crash Output and Stack Trace:
```
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 -O1 <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
 #0 0x0000000003b583f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b583f8)
 #1 0x0000000003b5653c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3b5653c)
 #2 0x0000000003aa58c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000748ae7242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x0000000006f6f3fa clang::ASTContext::forEachMultiversionedFunctionVersion(clang::FunctionDecl const*, llvm::function_ref<void (clang::FunctionDecl*)>) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x6f6f3fa)
 #5 0x00000000040d6ee5 clang::CodeGen::CodeGenModule::emitMultiVersionFunctions() (/opt/compiler-explorer/clang-trunk/bin/clang+0x40d6ee5)
 #6 0x00000000040d8de0 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-trunk/bin/clang+0x40d8de0)
 #7 0x00000000044d650e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
 #8 0x00000000044d353d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44d353d)
 #9 0x00000000060471ec clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x60471ec)
#10 0x00000000044d3e95 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x44d3e95)
#11 0x00000000047ae771 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x47ae771)
#12 0x000000000472f3ab clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x472f3ab)
#13 0x000000000489bbf3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x489bbf3)
#14 0x0000000000d668a1 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xd668a1)
#15 0x0000000000d5f00d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#16 0x0000000004520499 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
#17 0x0000000003aa5cf3 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x3aa5cf3)
#18 0x00000000045206b9 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
#19 0x00000000044e441d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x44e441d)
#20 0x00000000044e53b1 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+0x44e53b1)
#21 0x00000000044ef76c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x44ef76c)
#22 0x0000000000d634c1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xd634c1)
#23 0x0000000000c24d54 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xc24d54)
#24 0x0000748ae7229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#25 0x0000748ae7229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#26 0x0000000000d5eaa5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xd5eaa5)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
```


Source Code:
```c
#define int unsigned

struct foo {
  int a : 1;
};

int __attribute__((target_clones("default,avx"))) foo(a)
struct foo a;
{
 return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to