| Issue |
242652
|
| Summary |
[BPF] Segmentation fault when using C++ class methods
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
pitust
|
The following code crashes on eBPF targets:
```c++
struct T { void foo(); };
void bar(T* x) { x->foo(); }
```
[godbolt](https://godbolt.org/z/eT6saGnc6)
<details><summary>Crash log</summary>
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -fno-verbose-asm -S -target bpf -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '<source>'.
4. Running pass 'BPF Assembly Printer' on function '@_Z3barP1T'
#0 0x0000000004852cf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4852cf8)
#1 0x00000000048509dc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48509dc)
#2 0x000000000478dff0 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000071e83d445330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x000000000258286e llvm::BTFDebug::processDeclAnnotations(llvm::MDTupleTypedArrayWrapper<llvm::DINode>, unsigned int, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258286e)
#5 0x000000000258a608 llvm::BTFDebug::visitStructType(llvm::DICompositeType const*, bool, unsigned int&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258a608)
#6 0x000000000258b63f llvm::BTFDebug::visitTypeEntry(llvm::DIType const*, unsigned int&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258b63f)
#7 0x000000000258b984 llvm::BTFDebug::visitDerivedType(llvm::DIDerivedType const*, unsigned int&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258b984)
#8 0x000000000258b725 llvm::BTFDebug::visitTypeEntry(llvm::DIType const*, unsigned int&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258b725)
#9 0x000000000258c8a3 llvm::BTFDebug::visitSubroutineType(llvm::DISubroutineType const*, bool, llvm::SmallDenseMap<unsigned int, llvm::StringRef, 4u, llvm::DenseMapInfo<unsigned int, void>, llvm::detail::DenseMapPair<unsigned int, llvm::StringRef>> const&, unsigned int&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258c8a3)
#10 0x000000000258f12b llvm::BTFDebug::beginFunctionImpl(llvm::MachineFunction const*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x258f12b)
#11 0x0000000005b2f7ea llvm::AsmPrinter::emitFunctionHeader() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b2f7ea)
#12 0x0000000005b2ac5d llvm::AsmPrinter::emitFunctionBody() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5b2ac5d)
#13 0x000000000250f6c5 llvm::AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x250f6c5)
#14 0x0000000003c3f065 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c3f065)
#15 0x0000000004173f82 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4173f82)
#16 0x0000000004174361 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4174361)
#17 0x0000000004174e76 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4174e76)
#18 0x0000000005ae88f8 runCodeGenPipelineLegacy(llvm::TargetMachine&, llvm::Module&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::CodeGenFileType, bool, llvm::ModuleSummaryIndex const*, bool) RunCodeGen.cpp:0:0
#19 0x0000000005ae8a69 llvm::runCodeGenPipeline(llvm::TargetMachine&, llvm::Module&, llvm::raw_pwrite_stream&, llvm::raw_pwrite_stream*, llvm::CodeGenFileType, bool, bool, llvm::ModuleSummaryIndex const*, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5ae8a69)
#20 0x0000000004bf19bb (anonymous namespace)::EmitAssemblyHelper::emitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#21 0x0000000004bf1e84 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4bf1e84)
#22 0x000000000521feba clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x521feba)
#23 0x0000000008352e1c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x8352e1c)
#24 0x0000000005220ce5 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5220ce5)
#25 0x0000000005553361 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5553361)
#26 0x00000000054e4dd5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x54e4dd5)
#27 0x0000000005628bbb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5628bbb)
#28 0x000000000178a898 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x178a898)
#29 0x000000000178282b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#30 0x00000000017828d3 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#31 0x000000000529d079 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
#32 0x000000000478e383 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x478e383)
#33 0x000000000529dabd 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
#34 0x000000000525cb72 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x525cb72)
#35 0x000000000525fae4 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+++0x525fae4)
#36 0x000000000526dbfc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x526dbfc)
#37 0x0000000001787331 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1787331)
#38 0x0000000001715773 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0x1715773)
#39 0x000071e83d42a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#40 0x000071e83d42a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#41 0x00000000017822d5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0x17822d5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGSEGV (11)
Compiler returned: 139
```
</details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs