llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.66k stars 11.85k forks source link

crash with -fsemantic-interposition: "Alias cannot point to an interposable alias" #49810

Open nsz-arm opened 3 years ago

nsz-arm commented 3 years ago
Bugzilla Link 50466
Version trunk
OS Linux
CC @dwblaikie,@zygoloid

Extended Description

the following code uses various gnu extensions and compiles with gcc:

void b();

pragma redefine_extname b b_ext

void b() {} typeof(b) c asm("c_asm") attribute((alias("b_ext"))); typeof(b) a attribute((alias("c_asm"))); void try_a() { a(); } void try_b() { b(); } void try_c() { c(); }

with clang -fPIC -fsemantic-interposition, using a clang built with assertions, i see

Alias cannot point to an interposable alias void (...)* @​a fatal error: error in backend: Broken module found, compilation aborted! PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump:

  1. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -xc -fPIC -fsemantic-interposition
  2. parser at end of file
  3. Code generation

    ​0 0x000055a9640fa62c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x375562c)

    ​1 0x000055a9640f84e4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x37534e4)

    ​2 0x000055a9640f8765 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3753765)

    ​3 0x000055a9640531df llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36ae1df)

    ​4 0x000055a9640f23ee llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x374d3ee)

    ​5 0x000055a961d5168e LLVMErrorHandler(void*, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool) cc1_main.cpp:0:0

    ​6 0x000055a96405a859 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36b5859)

    ​7 0x000055a96405a9a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36b59a8)

    ​8 0x000055a963975f15 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x2fd0f15)

    ​9 0x000055a9638e7197 llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x2f42197)

    ​10 0x000055a9638f153b llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x2f4c53b)

    ​11 0x000055a9643d09a5 (anonymous namespace)::EmitAssemblyHelper::EmitAssemblyWithNewPassManager(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete >) BackendUtil.cpp:0:0

    ​12 0x000055a9643d41f3 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete >) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a2f1f3)

    ​13 0x000055a96506b7aa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46c67aa)

    ​14 0x000055a965ece4f9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x55294f9)

    ​15 0x000055a96506b948 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46c6948)

    ​16 0x000055a9649ea951 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4045951)

    ​17 0x000055a964986522 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fe1522)

    ​18 0x000055a964ab5f2a clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4110f2a)

    ​19 0x000055a961d5358c cc1_main(llvm::ArrayRef<char const>, char const, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13ae58c)

    ​20 0x000055a961d4e929 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0

    ​21 0x000055a96483d815 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::'lambda'()>(long) Job.cpp:0:0

    ​22 0x000055a964053023 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36ae023)

    ​23 0x000055a96483e1b4 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const (.part.161) Job.cpp:0:0

    ​24 0x000055a9648162ca clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e712ca)

    ​25 0x000055a964816f6f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e71f6f)

    ​26 0x000055a96482077a clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e7b77a)

    ​27 0x000055a961c7c698 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x12d7698)

    ​28 0x00007f61094980b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b3)

    ​29 0x000055a961d4e49a _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x13a949a)

    clang-13: error: clang frontend command failed with exit code 70 (use -v to see invocation) Compiler returned: 70

Endilll commented 1 year ago

Still crashing as of post-17 trunk: https://godbolt.org/z/cn7Wa5WWr

Alias cannot point to an interposable alias
ptr @a
fatal error: error in backend: Broken module found, compilation aborted!
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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -x c -Wno-implicit-int -Wno-implicit-function-declaration -fPIC -fsemantic-interposition <source>
1.  <eof> parser at end of file
2.  Code generation
 #0 0x0000000003673648 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3673648)
 #1 0x00000000036714cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x36714cc)
 #2 0x00000000035bf296 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35bf296)
 #3 0x0000000003668b6e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3668b6e)
 #4 0x0000000000bca2ba LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x00000000035c9c93 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35c9c93)
 #6 0x00000000035c9df8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35c9df8)
 #7 0x00000000030afa8d (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30afa8d)
 #8 0x0000000003008bfd llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3008bfd)
 #9 0x00000000030148a6 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x30148a6)
#10 0x00000000038e2ea0 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) BackendUtil.cpp:0:0
#11 0x00000000038e37c9 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>>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38e37c9)
#12 0x00000000048c68df clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c68df)
#13 0x0000000005d7ff09 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d7ff09)
#14 0x00000000048c50c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c50c8)
#15 0x000000000412d7d9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x412d7d9)
#16 0x00000000040b1b6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40b1b6e)
#17 0x000000000420da46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x420da46)
#18 0x0000000000bcb732 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcb732)
#19 0x0000000000bc3f1a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#20 0x0000000003f11a19 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
#21 0x00000000035bf1d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35bf1d4)
#22 0x0000000003f1200f 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
#23 0x0000000003ed9f75 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ed9f75)
#24 0x0000000003eda9dd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eda9dd)
#25 0x0000000003ee2505 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ee2505)
#26 0x0000000000bc99e7 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc99e7)
#27 0x0000000000ac3ab1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xac3ab1)
#28 0x00007f823bfa7083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x0000000000bc39fe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc39fe)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)