Skip to content

Clang SIGSEGV when compiling BPF target #147212

Open
@epoll-reactor-2

Description

@epoll-reactor-2

Minimal code snippet:

#include <linux/bpf.h> // Crashes.
// #include <linux/selinux_netlink.h> // Works like any other header.

int main() {}

Compile command that works correctly:

$ clang-21 -g -I/lib/modules/$(uname -r)/build/include -c c.c -o c.o
OR
$ clang-21 -target bpf -I/lib/modules/$(uname -r)/build/include -c c.c -o c.o
In file included from c.c:1:
In file included from /lib/modules/6.8.0-63-generic/build/include/linux/bpf.h:8:
In file included from /lib/modules/6.8.0-63-generic/build/include/uapi/linux/filter.h:9:
/lib/modules/6.8.0-63-generic/build/include/linux/compiler.h:266:10: fatal error: 'asm/rwonce.h' file not found
  266 | #include <asm/rwonce.h>
      |          ^~~~~~~~~~~~~~
1 error generated.

Just no header.

Compile command that crashes. Constraints:

  1. -g in combination with -target bpf crashes compilation.
  2. If program is compiled with only one of the flags: -g or -target bpf, compilation does not crashes.
$ clang-21 -H -g -I/lib/modules/$(uname -r)/build/include -target bpf -c c.c -o c.o
In file included from c.c:1:
In file included from /lib/modules/6.8.0-63-generic/build/include/linux/bpf.h:7:
In file included from /lib/modules/6.8.0-63-generic/build/include/uapi/linux/bpf.h:11:
In file included from /lib/modules/6.8.0-63-generic/build/include/linux/types.h:6:
/lib/modules/6.8.0-63-generic/build/include/uapi/linux/types.h:5:10: fatal error: 'asm/types.h' file not found
    5 | #include <asm/types.h>
      |          ^~~~~~~~~~~~~
... <preprocessed sources list above>
..... /lib/modules/6.8.0-63-generic/build/include/linux/mempool.h
..... /lib/modules/6.8.0-63-generic/build/include/linux/uio.h
...... /lib/modules/6.8.0-63-generic/build/include/uapi/linux/uio.h
.. /lib/modules/6.8.0-63-generic/build/include/linux/cfi.h
.. /lib/modules/6.8.0-63-generic/build/include/linux/bpf_types.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-21 -H -g -I/lib/modules/6.8.0-63-generic/build/include -target bpf -c c.c -o c.o
1.	<eof> parser at end of file
 #0 0x000073059d416e46 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-21/bin/../lib/libLLVM.so.21.0+0x1016e46)
 #1 0x000073059d414af0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-21/bin/../lib/libLLVM.so.21.0+0x1014af0)
 #2 0x000073059d4162a4 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/llvm-21/bin/../lib/libLLVM.so.21.0+0x10162a4)
 #3 0x000073059d35ee30 (/usr/lib/llvm-21/bin/../lib/libLLVM.so.21.0+0xf5ee30)
 #4 0x000073059bc45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007305a5ff78b5 clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x11f78b5)
 #6 0x00007305a5a2b175 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xc2b175)
 #7 0x00007305a5a2c91c clang::ASTContext::getTypeInfo(clang::Type const*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xc2c91c)
 #8 0x00007305a5a2b0e1 clang::ASTContext::getTypeInfoImpl(clang::Type const*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xc2b0e1)
 #9 0x00007305a5a2c66e clang::ASTContext::getTypeInfoInChars(clang::Type const*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xc2c66e)
#10 0x00007305a5a2c500 clang::ASTContext::getTypeInfoInChars(clang::QualType) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xc2c500)
#11 0x00007305a6001bb4 (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1201bb4)
#12 0x00007305a5fffde0 (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x11ffde0)
#13 0x00007305a5ff7c3a clang::ASTContext::getASTRecordLayout(clang::RecordDecl const*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x11f7c3a)
#14 0x00007305a6c374ae clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e374ae)
#15 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#16 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#17 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#18 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#19 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#20 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#21 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#22 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#23 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#24 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#25 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#26 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#27 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#28 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#29 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#30 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#31 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#32 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#33 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#34 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#35 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#36 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#37 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#38 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#39 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#40 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#41 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#42 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#43 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#44 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#45 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#46 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#47 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#48 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#49 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#50 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#51 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#52 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#53 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#54 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#55 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#56 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#57 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#58 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#59 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#60 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#61 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#62 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#63 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#64 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#65 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#66 0x00007305a6c36762 clang::CodeGen::CGDebugInfo::createFieldType(llvm::StringRef, clang::QualType, clang::SourceLocation, clang::AccessSpecifier, unsigned long, unsigned int, llvm::DIFile*, llvm::DIScope*, clang::RecordDecl const*, llvm::MDTupleTypedArrayWrapper<llvm::DINode>) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e36762)
#67 0x00007305a6c37336 clang::CodeGen::CGDebugInfo::CollectRecordNormalField(clang::FieldDecl const*, unsigned long, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*, clang::RecordDecl const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e37336)
#68 0x00007305a6c3750b clang::CodeGen::CGDebugInfo::CollectRecordFields(clang::RecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DICompositeType*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3750b)
#69 0x00007305a6c3a9a2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3a9a2)
#70 0x00007305a6c3aee6 clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e3aee6)
#71 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#72 0x00007305a6c32d57 clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e32d57)
#73 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#74 0x00007305a6c35f40 clang::CodeGen::CGDebugInfo::CreateType(clang::FunctionType const*, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e35f40)
#75 0x00007305a6c2ef02 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e2ef02)
#76 0x00007305a6c42145 clang::CodeGen::CGDebugInfo::EmitFunctionDecl(clang::GlobalDecl, clang::SourceLocation, clang::QualType, llvm::Function*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1e42145)
#77 0x00007305a6347a9d clang::Sema::ActOnEndOfTranslationUnit() (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x1547a9d)
#78 0x00007305a5a058f2 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xc058f2)
#79 0x00007305a594f0ce clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0xb4f0ce)
#80 0x00007305a75605eb clang::FrontendAction::Execute() (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x27605eb)
#81 0x00007305a74dbfe4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x26dbfe4)
#82 0x00007305a75e3cce clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x27e3cce)
#83 0x0000646929ada063 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-21/bin/clang+0x12063)
#84 0x0000646929ad6ef5 (/usr/lib/llvm-21/bin/clang+0xeef5)
#85 0x00007305a71c5cf9 (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x23c5cf9)
#86 0x000073059d35ebc8 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/llvm-21/bin/../lib/libLLVM.so.21.0+0xf5ebc8)
#87 0x00007305a71c580d clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x23c580d)
#88 0x00007305a718e806 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x238e806)
#89 0x00007305a718e9be clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x238e9be)
#90 0x00007305a71a9c0d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/llvm-21/bin/../lib/libclang-cpp.so.21.0+0x23a9c0d)
#91 0x0000646929ad69f7 clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-21/bin/clang+0xe9f7)
#92 0x0000646929ae32e6 main (/usr/lib/llvm-21/bin/clang+0x1b2e6)
#93 0x000073059bc2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#94 0x000073059bc2a28b call_init ./csu/../csu/libc-start.c:128:20
#95 0x000073059bc2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#96 0x0000646929ad4d2e _start (/usr/lib/llvm-21/bin/clang+0xcd2e)
clang-21: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 21.0.0 (++20250310052704+a5763048b63b-1~exp1~20250310172827.1340)
Target: bpf
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
clang-21: note: diagnostic msg: Error generating preprocessed source(s).

Following Clang versions were tested and gives the same crash:

Ubuntu clang version 14.0.6
Ubuntu clang version 15.0.7
Ubuntu clang version 21.0.0 (++20250310052704+a5763048b63b-1~exp1~20250310172827.1340)

Disassembled instruction leading to crash:

00000000011f77f0 <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0>:
 11f77f0:       55                      push   %rbp
 11f77f1:       41 57                   push   %r15
 11f77f3:       41 56                   push   %r14
 11f77f5:       41 55                   push   %r13
 11f77f7:       41 54                   push   %r12
 11f77f9:       53                      push   %rbx
 11f77fa:       48 81 ec 78 05 00 00    sub    $0x578,%rsp
 11f7801:       48 89 f3                mov    %rsi,%rbx
 11f7804:       49 89 fd                mov    %rdi,%r13
 11f7807:       64 48 8b 04 25 28 00    mov    %fs:0x28,%rax
 11f780e:       00 00 
 11f7810:       48 89 84 24 70 05 00    mov    %rax,0x570(%rsp)
 11f7817:       00 
 11f7818:       f6 46 48 80             testb  $0x80,0x48(%rsi)
 11f781c:       74 20                   je     11f783e <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0+0x4e>
 11f781e:       48 89 df                mov    %rbx,%rdi
 11f7821:       e8 ca 7b bf ff          call   def3f0 <_ZNK5clang7TagDecl13getDefinitionEv@@LLVM_21.0>
 11f7826:       48 85 c0                test   %rax,%rax
 11f7829:       75 13                   jne    11f783e <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0+0x4e>
 11f782b:       49 8b bd 30 47 00 00    mov    0x4730(%r13),%rdi
 11f7832:       48 8b 07                mov    (%rdi),%rax
 11f7835:       48 89 de                mov    %rbx,%rsi
 11f7838:       ff 90 98 00 00 00       call   *0x98(%rax)
 11f783e:       48 8b 73 68             mov    0x68(%rbx),%rsi
 11f7842:       48 8d 7e 60             lea    0x60(%rsi),%rdi
 11f7846:       e8 c5 ea a1 ff          call   c16310 <_ZN5clang15LinkageComputer13getLVForValueERKNS_7APValueENS_17LVComputationKindE@@LLVM_21.0+0x830>
 11f784b:       48 89 df                mov    %rbx,%rdi
 11f784e:       e8 9d 7b bf ff          call   def3f0 <_ZNK5clang7TagDecl13getDefinitionEv@@LLVM_21.0>
 11f7853:       48 89 84 24 00 01 00    mov    %rax,0x100(%rsp)
 11f785a:       00 
 11f785b:       4d 8d b5 18 04 00 00    lea    0x418(%r13),%r14
 11f7862:       48 8d b4 24 00 01 00    lea    0x100(%rsp),%rsi
 11f7869:       00 
 11f786a:       4c 89 f7                mov    %r14,%rdi
 11f786d:       e8 0e 2f 00 00          call   11fa780 <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0+0x2f90>
 11f7872:       48 8b 28                mov    (%rax),%rbp
 11f7875:       48 85 ed                test   %rbp,%rbp
 11f7878:       0f 85 ca 2b 00 00       jne    11fa448 <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0+0x2c58>
 11f787e:       49 8b 85 88 08 00 00    mov    0x888(%r13),%rax
 11f7885:       f6 40 3c 10             testb  $0x10,0x3c(%rax)
 11f7889:       74 1b                   je     11f78a6 <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0+0xb6>
 11f788b:       f6 40 59 04             testb  $0x4,0x59(%rax)
 11f788f:       0f 94 c1                sete   %cl
 11f7892:       49 8b 85 a8 43 00 00    mov    0x43a8(%r13),%rax
 11f7899:       48 85 c0                test   %rax,%rax
 11f789c:       0f 94 c2                sete   %dl
 11f789f:       08 ca                   or     %cl,%dl
 11f78a1:       80 fa 01                cmp    $0x1,%dl
 11f78a4:       75 07                   jne    11f78ad <_ZNK5clang10ASTContext18getASTRecordLayoutEPKNS_10RecordDeclE@@LLVM_21.0+0xbd>
 11f78a6:       49 8b 85 a0 43 00 00    mov    0x43a0(%r13),%rax
 11f78ad:       4c 8b a4 24 00 01 00    mov    0x100(%rsp),%r12
 11f78b4:       00 
 11f78b5:       41 8b 4c 24 1c          mov    0x1c(%r12),%ecx      <<<<<<<<<<<<< There
 11f78ba:       83 e1 7f                and    $0x7f,%ecx
 11f78bd:       83 c1 c2                add    $0xffffffc2,%ecx
 11f78c0:       83 f9 fd                cmp    $0xfffffffd,%ecx
 11f78c3:       0f 92 c2                setb   %dl
 11f78c6:       4d 85 e4                test   %r12,%r12

End of <linux/bpf_types.h>:

BPF_LINK_TYPE(BPF_LINK_TYPE_KPROBE_MULTI, kprobe_multi)
BPF_LINK_TYPE(BPF_LINK_TYPE_STRUCT_OPS, struct_ops)
BPF_LINK_TYPE(BPF_LINK_TYPE_UPROBE_MULTI, uprobe_multi)
<no newline at the end of file>

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]debuginfo

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions