llvm / llvm-project

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

[bug] [x86_64] [ubuntu22.04] clang crash when compiling to bpf #90697

Open kohshi54 opened 4 months ago

kohshi54 commented 4 months ago

Hello. clang crashed with exit code 139 when trying to compile to bpf bytecode. Stack dump:

0.  Program arguments: clang -v -target bpf -I/usr/include/x86_64-linux-gnu -I/usr/src/linux-hwe-6.5-headers-6.5.0-28/include/ -g -c hello.bpf.c
1.  <eof> parser at end of file
 #0 0x00007b4db023fd01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01)
 #1 0x00007b4db023da3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e)
 #2 0x00007b4db023f0ab llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3f0ab)
 #3 0x00007b4db016bdff (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bdff)
 #4 0x00007b4daec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007b4db6c257ce clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe257ce)
 #6 0x00007b4db68e5f0c clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5f0c)
 #7 0x00007b4db68e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96)
 #8 0x00007b4db68e5e2e clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5e2e)
 #9 0x00007b4db68e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96)
#10 0x00007b4db68e6a59 clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6a59)
#11 0x00007b4db6c30d64 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe30d64)
#12 0x00007b4db6c2d316 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe2d316)
#13 0x00007b4db6c25bd9 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe25bd9)
#14 0x00007b4db791bcd3 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1bcd3)
#15 0x00007b4db7a07472 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c07472)
#16 0x00007b4db7a06554 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c06554)
#17 0x00007b4db7a0646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f)
#18 0x00007b4db7a0698c clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0698c)
#19 0x00007b4db7a0646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f)
#20 0x00007b4db7920390 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b20390)
#21 0x00007b4db791cddf (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1cddf)
#22 0x00007b4db791bd88 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1bd88)
#23 0x00007b4db7a07472 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c07472)
#24 0x00007b4db7a06554 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c06554)
#25 0x00007b4db7a0646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f)
#26 0x00007b4db79a521c clang::CodeGen::CodeGenModule::EmitExternalVarDeclaration(clang::VarDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1ba521c)
#27 0x00007b4db6f1e962 clang::Sema::ActOnEndOfTranslationUnit() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x111e962)
#28 0x00007b4db68c1c86 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xac1c86)
#29 0x00007b4db68048dd clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa048dd)
#30 0x00007b4db7978b71 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b78b71)
#31 0x00007b4db8314b57 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2514b57)
#32 0x00007b4db826c3a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246c3a6)
#33 0x00007b4db838e45b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x258e45b)
#34 0x000000000041328b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-14/bin/clang+0x41328b)
#35 0x00000000004114bc (/usr/lib/llvm-14/bin/clang+0x4114bc)
#36 0x00007b4db7eeaed2 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20eaed2)
#37 0x00007b4db016bb6d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bb6d)
#38 0x00007b4db7eea9c0 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20ea9c0)
#39 0x00007b4db7eb5183 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b5183)
#40 0x00007b4db7eb540a clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b540a)
#41 0x00007b4db7ecf507 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20cf507)
#42 0x0000000000410f26 main (/usr/lib/llvm-14/bin/clang+0x410f26)
#43 0x00007b4daec29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#44 0x00007b4daec29e40 call_init ./csu/../csu/libc-start.c:128:20
#45 0x00007b4daec29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#46 0x000000000040e3b5 _start (/usr/lib/llvm-14/bin/clang+0x40e3b5)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: bpf
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: Error generating preprocessed source(s).
llvmbot commented 4 months ago

@llvm/issue-subscribers-clang-codegen

Author: Kohshi.Y (kohshi54)

Hello. clang crashed with exit code 139 when trying to compile to bpf bytecode. Stack dump: 0. Program arguments: clang -v -target bpf -I/usr/include/x86_64-linux-gnu -I/usr/src/linux-hwe-6.5-headers-6.5.0-28/include/ -g -c hello.bpf.c 1. <eof> parser at end of file #0 0x00007b4db023fd01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01) #1 0x00007b4db023da3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e) #2 0x00007b4db023f0ab llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3f0ab) #3 0x00007b4db016bdff (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bdff) #4 0x00007b4daec42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520) #5 0x00007b4db6c257ce clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe257ce) #6 0x00007b4db68e5f0c clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5f0c) #7 0x00007b4db68e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96) #8 0x00007b4db68e5e2e clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5e2e) #9 0x00007b4db68e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96) #10 0x00007b4db68e6a59 clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6a59) #11 0x00007b4db6c30d64 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe30d64) #12 0x00007b4db6c2d316 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe2d316) #13 0x00007b4db6c25bd9 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe25bd9) #14 0x00007b4db791bcd3 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1bcd3) #15 0x00007b4db7a07472 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c07472) #16 0x00007b4db7a06554 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c06554) #17 0x00007b4db7a0646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f) #18 0x00007b4db7a0698c clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0698c) #19 0x00007b4db7a0646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f) #20 0x00007b4db7920390 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b20390) #21 0x00007b4db791cddf (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1cddf) #22 0x00007b4db791bd88 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1bd88) #23 0x00007b4db7a07472 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c07472) #24 0x00007b4db7a06554 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c06554) #25 0x00007b4db7a0646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f) #26 0x00007b4db79a521c clang::CodeGen::CodeGenModule::EmitExternalVarDeclaration(clang::VarDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1ba521c) #27 0x00007b4db6f1e962 clang::Sema::ActOnEndOfTranslationUnit() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x111e962) #28 0x00007b4db68c1c86 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xac1c86) #29 0x00007b4db68048dd clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa048dd) #30 0x00007b4db7978b71 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b78b71) #31 0x00007b4db8314b57 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2514b57) #32 0x00007b4db826c3a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246c3a6) #33 0x00007b4db838e45b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x258e45b) #34 0x000000000041328b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-14/bin/clang+0x41328b) #35 0x00000000004114bc (/usr/lib/llvm-14/bin/clang+0x4114bc) #36 0x00007b4db7eeaed2 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20eaed2) #37 0x00007b4db016bb6d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bb6d) #38 0x00007b4db7eea9c0 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, bool*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20ea9c0) #39 0x00007b4db7eb5183 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b5183) #40 0x00007b4db7eb540a clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b540a) #41 0x00007b4db7ecf507 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20cf507) #42 0x0000000000410f26 main (/usr/lib/llvm-14/bin/clang+0x410f26) #43 0x00007b4daec29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16 #44 0x00007b4daec29e40 call_init ./csu/../csu/libc-start.c:128:20 #45 0x00007b4daec29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5 #46 0x000000000040e3b5 _start (/usr/lib/llvm-14/bin/clang+0x40e3b5) clang: error: clang frontend command failed with exit code 139 (use -v to see invocation) Ubuntu clang version 14.0.0-1ubuntu1.1 Target: bpf Thread model: posix InstalledDir: /usr/bin clang: note: diagnostic msg: Error generating preprocessed source(s).