Skip to content

[EBPF] fatal error: error in backend: Branch target out of insn range #134462

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

Open
Cryp70m4n opened this issue Apr 4, 2025 · 2 comments
Open
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mc Machine (object) code

Comments

@Cryp70m4n
Copy link

Cryp70m4n commented Apr 4, 2025

fatal error: error in backend: Branch target out of insn range
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 -O3 -g -target bpf -c src/bpf/mon.bpf.c -o mon.bpf.o
1.	<eof> parser at end of file
2.	Code generation
 #0 0x00007b3b06a1a730 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/libLLVM.so.19.1+0x81a730)
 #1 0x00007b3b06a17bf5 llvm::sys::CleanupOnSignal(unsigned long) (/usr/lib/libLLVM.so.19.1+0x817bf5)
 #2 0x00007b3b0690187a llvm::CrashRecoveryContext::HandleExit(int) (/usr/lib/libLLVM.so.19.1+0x70187a)
 #3 0x00007b3b06a10766 llvm::sys::Process::Exit(int, bool) (/usr/lib/libLLVM.so.19.1+0x810766)
 #4 0x00005f34a5caa1a6 (/usr/bin/clang-19+0xc1a6)
 #5 0x00007b3b0691a035 llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/libLLVM.so.19.1+0x71a035)
 #6 0x00007b3b0691a1ee (/usr/lib/libLLVM.so.19.1+0x71a1ee)
 #7 0x00007b3b0a48ace1 (/usr/lib/libLLVM.so.19.1+0x428ace1)
 #8 0x00007b3b08cc5bf9 llvm::MCAssembler::layout() (/usr/lib/libLLVM.so.19.1+0x2ac5bf9)
 #9 0x00007b3b08cc5dc5 llvm::MCAssembler::Finish() (/usr/lib/libLLVM.so.19.1+0x2ac5dc5)
#10 0x00007b3b077602aa llvm::AsmPrinter::doFinalization(llvm::Module&) (/usr/lib/libLLVM.so.19.1+0x15602aa)
#11 0x00007b3b06be228d llvm::FPPassManager::doFinalization(llvm::Module&) (/usr/lib/libLLVM.so.19.1+0x9e228d)
#12 0x00007b3b06beeb29 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/libLLVM.so.19.1+0x9eeb29)
#13 0x00007b3b10136774 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>>, clang::BackendConsumer*) (/usr/lib/libclang-cpp.so.19.1+0x1736774)
#14 0x00007b3b104ffb7a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/libclang-cpp.so.19.1+0x1affb7a)
#15 0x00007b3b0efd9c86 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/libclang-cpp.so.19.1+0x5d9c86)
#16 0x00007b3b10cfa221 clang::FrontendAction::Execute() (/usr/lib/libclang-cpp.so.19.1+0x22fa221)
#17 0x00007b3b10c9008f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/libclang-cpp.so.19.1+0x229008f)
#18 0x00007b3b10d54ba5 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/libclang-cpp.so.19.1+0x2354ba5)
#19 0x00005f34a5cb0832 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-19+0x12832)
#20 0x00005f34a5cb504e (/usr/bin/clang-19+0x1704e)
#21 0x00007b3b10964bb5 (/usr/lib/libclang-cpp.so.19.1+0x1f64bb5)
#22 0x00007b3b0690176a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/lib/libLLVM.so.19.1+0x70176a)
#23 0x00007b3b1096bb76 (/usr/lib/libclang-cpp.so.19.1+0x1f6bb76)
#24 0x00007b3b10922709 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/lib/libclang-cpp.so.19.1+0x1f22709)
#25 0x00007b3b10922afc clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/usr/lib/libclang-cpp.so.19.1+0x1f22afc)
#26 0x00007b3b10992a64 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/usr/lib/libclang-cpp.so.19.1+0x1f92a64)
#27 0x00005f34a5cb6d8c clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-19+0x18d8c)
#28 0x00005f34a5ca8f65 main (/usr/bin/clang-19+0xaf65)
#29 0x00007b3b05c35488 (/usr/lib/libc.so.6+0x27488)
#30 0x00007b3b05c3554c __libc_start_main (/usr/lib/libc.so.6+0x2754c)
#31 0x00005f34a5ca8fc5 _start (/usr/bin/clang-19+0xafc5)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 19.1.7
Target: bpf
Thread model: posix
InstalledDir: /usr/bin
clang: note: diagnostic msg: 

mon-0e715b.c.txt
mon-0e715b.sh.txt

The core of the issue are if checks in the main part of the program if you do up to 36 program compiles normally but everything over it will make the compiler yield the error.

    if (payload_size == sizeof(PAYLOAD_REQUEST) + 37) {
        ret_value = check_request(payload, payload_size, data_end, ip, tcp);
    }

if you remove this program will compile normally

@EugeneZelenko EugeneZelenko added mc Machine (object) code crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Apr 5, 2025
@EugeneZelenko
Copy link
Contributor

Could you please try 20 or main branch?

@Cryp70m4n
Copy link
Author

Tried version 20.1.2 and ran into same issue.

fatal error: error in backend: Branch target out of insn range
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: ./llvm/LLVM-20.1.2-Linux-X64/bin/clang -O3 -g -target bpf -c src/bpf/mon.bpf.c -o mon.bpf.o
1.	<eof> parser at end of file
2.	Code generation
 #0 0x0000594c8b215707 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x8015707)
 #1 0x0000594c8b21549d llvm::sys::CleanupOnSignal(unsigned long) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x801549d)
 #2 0x0000594c8b1c47fe (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #3 0x0000594c8b1c47bb (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x7fc47bb)
 #4 0x0000594c8b2134c7 llvm::sys::Process::Exit(int, bool) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x80134c7)
 #5 0x0000594c89bda839 (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x69da839)
 #6 0x0000594c8b1c80cb llvm::report_fatal_error(llvm::Twine const&, bool) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x7fc80cb)
 #7 0x0000594c87c7f635 (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x4a7f635)
 #8 0x0000594c8a3da1cf (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x71da1cf)
 #9 0x0000594c8edab1e0 llvm::MCAssembler::layout() (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xbbab1e0)
#10 0x0000594c8edaa5f1 llvm::MCObjectStreamer::finishImpl() (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xbbaa5f1)
#11 0x0000594c8edaa542 llvm::MCELFStreamer::finishImpl() (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xbbaa542)
#12 0x0000594c8e26ee55 llvm::AsmPrinter::doFinalization(llvm::Module&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb06ee55)
#13 0x0000594c8dc1b070 llvm::FPPassManager::doFinalization(llvm::Module&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xaa1b070)
#14 0x0000594c8e7c0cac llvm::legacy::PassManagerImpl::run(llvm::Module&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb5c0cac)
#15 0x0000594c8ea9a53b clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb89a53b)
#16 0x0000594c88c31e7d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0x5a31e7d)
#17 0x0000594c8e34763f clang::ParseAST(clang::Sema&, bool, bool) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb14763f)
#18 0x0000594c8ebbda9d clang::FrontendAction::Execute() (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb9bda9d)
#19 0x0000594c8eb005dd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb9005dd)
#20 0x0000594c8eb00414 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb900414)
#21 0x0000594c8eaffbe3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8ffbe3)
#22 0x0000594c8eafc583 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x0000594c8eafc42d void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#24 0x0000594c8eafc404 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8fc404)
#25 0x0000594c8eafc2f5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8fc2f5)
#26 0x0000594c8eafc06a clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8fc06a)
#27 0x0000594c8eafbbc0 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8fbbc0)
#28 0x0000594c8eafddd6 clang_main(int, char**, llvm::ToolContext const&) (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8fddd6)
#29 0x0000594c8eafd292 main (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb8fd292)
#30 0x0000783280a0c488 (/usr/lib/libc.so.6+0x27488)
#31 0x0000783280a0c54c __libc_start_main (/usr/lib/libc.so.6+0x2754c)
#32 0x0000594c8e9258ab _start (./llvm/LLVM-20.1.2-Linux-X64/bin/clang+0xb7258ab)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
Target: bpf
Thread model: posix
InstalledDir: /home/mrpascal/contributions/llvm/LLVM-20.1.2-Linux-X64/bin
clang: note: diagnostic msg: 

mon-4f0897.c.txt
mon-4f0897.sh.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] mc Machine (object) code
Projects
None yet
Development

No branches or pull requests

3 participants