Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kohshi54 opened this issue May 1, 2024 · 8 comments
Closed

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

kohshi54 opened this issue May 1, 2024 · 8 comments
Labels
clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid]

Comments

@kohshi54
Copy link

kohshi54 commented May 1, 2024

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).
@github-actions github-actions bot added the clang Clang issues not falling into any other category label May 1, 2024
@EugeneZelenko EugeneZelenko added clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels May 1, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented May 1, 2024

@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).

@yonghong-song
Copy link
Contributor

Could you provide a reproducible test case?

@kohshi54
Copy link
Author

kohshi54 commented Sep 28, 2024

Thanks for the reply. This code reproduces the bug.

$ uname -a
Linux pxubuntu102 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ cat hello.bpf.c
#include <linux/bpf.h>

SEC("xdp")
int hello(struct xdp_md *ctx) {
	return XDP_PASS;
}

char LICENSE[] SEC("license") = "Dual BSD/GPL";
$ clang -v -target bpf -I/usr/src/linux-hwe-6.8-headers-6.8.0-40/include -g -c hello.bpf.c
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: bpf
Thread model: posix
InstalledDir: /usr/bin
 (in-process)
 "/usr/lib/llvm-14/bin/clang" -cc1 -triple bpf -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name hello.bpf.c -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/kohshi54/eBPF-Tutorial/test/bug-repro -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I /usr/src/linux-hwe-6.8-headers-6.8.0-40/include -fdebug-compilation-dir=/home/kohshi54/eBPF-Tutorial/test/bug-repro -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o hello.bpf.o -x c hello.bpf.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
 /usr/src/linux-hwe-6.8-headers-6.8.0-40/include
 /usr/local/include
 /usr/lib/llvm-14/lib/clang/14.0.0/include
 /usr/include
End of search list.
In file included from hello.bpf.c:1:
In file included from /usr/src/linux-hwe-6.8-headers-6.8.0-40/include/linux/bpf.h:8:
In file included from /usr/src/linux-hwe-6.8-headers-6.8.0-40/include/uapi/linux/filter.h:9:
/usr/src/linux-hwe-6.8-headers-6.8.0-40/include/linux/compiler.h:251:10: fatal error: 'asm/rwonce.h' file not found
#include <asm/rwonce.h>
         ^~~~~~~~~~~~~~
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 -v -target bpf -I/usr/src/linux-hwe-6.8-headers-6.8.0-40/include -g -c hello.bpf.c
1.	<eof> parser at end of file
 #0 0x0000709fbb03fd01 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3fd01)
 #1 0x0000709fbb03da3e llvm::sys::RunSignalHandlers() (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3da3e)
 #2 0x0000709fbb03f0ab llvm::sys::CleanupOnSignal(unsigned long) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xe3f0ab)
 #3 0x0000709fbaf6bdff (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bdff)
 #4 0x0000709fb9a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x0000709fc1a257ce clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe257ce)
 #6 0x0000709fc16e5f0c clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5f0c)
 #7 0x0000709fc16e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96)
 #8 0x0000709fc16e5e2e clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5e2e)
 #9 0x0000709fc16e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96)
#10 0x0000709fc16e6a59 clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6a59)
#11 0x0000709fc1a30d64 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe30d64)
#12 0x0000709fc1a2d316 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe2d316)
#13 0x0000709fc1a25bd9 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe25bd9)
#14 0x0000709fc271bcd3 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1bcd3)
#15 0x0000709fc2807472 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c07472)
#16 0x0000709fc2806554 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c06554)
#17 0x0000709fc280646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f)
#18 0x0000709fc280698c clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0698c)
#19 0x0000709fc280646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f)
#20 0x0000709fc2720390 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b20390)
#21 0x0000709fc271cddf (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1cddf)
#22 0x0000709fc271bd88 clang::CodeGen::CodeGenTypes::ComputeRecordLayout(clang::RecordDecl const*, llvm::StructType*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b1bd88)
#23 0x0000709fc2807472 clang::CodeGen::CodeGenTypes::ConvertRecordDeclType(clang::RecordDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c07472)
#24 0x0000709fc2806554 clang::CodeGen::CodeGenTypes::ConvertType(clang::QualType) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c06554)
#25 0x0000709fc280646f clang::CodeGen::CodeGenTypes::ConvertTypeForMem(clang::QualType, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1c0646f)
#26 0x0000709fc27a521c clang::CodeGen::CodeGenModule::EmitExternalVarDeclaration(clang::VarDecl const*) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1ba521c)
#27 0x0000709fc1d1e962 clang::Sema::ActOnEndOfTranslationUnit() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x111e962)
#28 0x0000709fc16c1c86 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xac1c86)
#29 0x0000709fc16048dd clang::ParseAST(clang::Sema&, bool, bool) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xa048dd)
#30 0x0000709fc2778b71 clang::CodeGenAction::ExecuteAction() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x1b78b71)
#31 0x0000709fc3114b57 clang::FrontendAction::Execute() (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x2514b57)
#32 0x0000709fc306c3a6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x246c3a6)
#33 0x0000709fc318e45b 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 0x0000709fc2ceaed2 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20eaed2)
#37 0x0000709fbaf6bb6d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib/x86_64-linux-gnu/libLLVM-14.so.1+0xd6bb6d)
#38 0x0000709fc2cea9c0 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 0x0000709fc2cb5183 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0x20b5183)
#40 0x0000709fc2cb540a 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 0x0000709fc2ccf507 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 0x0000709fb9a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#44 0x0000709fb9a29e40 call_init ./csu/../csu/libc-start.c:128:20
#45 0x0000709fb9a29e40 __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).

@yonghong-song
Copy link
Contributor

Okay, the error is:

/usr/src/linux-hwe-6.8-headers-6.8.0-40/include/linux/compiler.h:251:10: fatal error: 'asm/rwonce.h' file not found
#include <asm/rwonce.h>

I guess You may need to add path for asm/rwonce.h.

@kohshi54
Copy link
Author

I understand that but still, compiler program causes segmentation fault. So, I thought it was a bug. Or segfault is tolerated in this case?

@yonghong-song
Copy link
Contributor

The seg fault happens in

#5 0x0000709fc1a257ce clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe257ce)
 #6 0x0000709fc16e5f0c clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5f0c)
 #7 0x0000709fc16e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96)
 #8 0x0000709fc16e5e2e clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae5e2e)
 #9 0x0000709fc16e6d96 clang::ASTContext::getTypeInfo(clang::Type const*) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6d96)
#10 0x0000709fc16e6a59 clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xae6a59)
#11 0x0000709fc1a30d64 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe30d64)
#12 0x0000709fc1a2d316 (/lib/x86_64-linux-gnu/libclang-cpp.so.14+0xe2d316)

which is not related to bpf backend. In llvm, it does have cases where after some diag reporting, the compiler continues to do normal work and it may cause internal error/fault due to previous errors.

@kohshi54
Copy link
Author

Okay, I understood. Thanks for explaining!

@EugeneZelenko
Copy link
Contributor

@kohshi54: Could you please try 19 or main branch? https://godbolt.org should be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen crash Prefer [crash-on-valid] or [crash-on-invalid]
Projects
None yet
Development

No branches or pull requests

5 participants