Skip to content

[BOLT][AARCH64] Bolt crashed while instrumenting the aarch64 shared library with realocation #168027

@wdxx

Description

@wdxx

Hi,
When I was instrumenting libUnreal.so, the bolt tool crashed.It looks like get invalid symbol for some relocation in function RewriteInstance::handleRelocation.

diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 8d6731e7540a..4fce92b94e93 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3027,6 +3027,12 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
         ReferencedSymbol =
             BC->getOrCreateGlobalSymbol(SymbolAddress, "SYMBOLat");
       } else {
+       {
+          auto Itr = Rel.getSymbol();
+          if (Itr == InputFile->symbol_end()) {
+            BC->outs() << "Get Invalid Symbol?\n";
+          }
+        }
         SymbolRef Symbol = *Rel.getSymbol();
         const uint64_t SymbolSize =
             IsAArch64 ? 0 : ELFSymbolRef(Symbol).getSize();

Bolt source code version

llvmorg-21.1.4

command line

bin/llvm-bolt  -instrument libUnreal-rel.so  -o libUnreal-instr.so --instrumentation-file=/data/local/tmp/prof.fdata --instrumentation-sleep-time=3

bolt log

BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: Target architecture: aarch64
BOLT-INFO: BOLT version: cdbf243f8669b241fca9682a0ebc3d62b4d27f7c
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x16400000, offset 0x16400000
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
BOLT-WARNING: ignoring data marker conflicting with function symbol _armv8_sha512_probe
Get Invalid Symbol?
Failure value returned from cantFail wrapped call
can't read an entry at 0x2628030: it goes past the end of the section (0x2628030)
UNREACHABLE executed at  /llvm/llvm-project/llvm/include/llvm/Support/Error.h:810!
 #0 0x000055cdd4f6c9cc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)  /llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:834:22
 #1 0x000055cdd4f6ce49 PrintStackTraceSignalHandler(void*)  /llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:916:1
 #2 0x000055cdd4f6a03d llvm::sys::RunSignalHandlers()  /llvm/llvm-project/llvm/lib/Support/Signals.cpp:104:20
 #3 0x000055cdd4f6c1f4 SignalHandler(int, siginfo_t*, void*)  /llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:426:14
 #4 0x000014d25b24f520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x000014d25b2a39fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x000014d25b2a39fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x000014d25b2a39fc pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x000014d25b24f476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x000014d25b2357f3 abort ./stdlib/abort.c:81:7
#10 0x000055cdd4e97b11 bindingsErrorHandler(void*, char const*, bool)  /llvm/llvm-project/llvm/lib/Support/ErrorHandling.cpp:253:55
#11 0x000055cdd43d59e2 unsigned int llvm::cantFail<unsigned int>(llvm::Expected<unsigned int>, char const*)  /llvm/llvm-project/llvm/include/llvm/Support/Error.h:812:1
#12 0x000055cdd50cc366 llvm::bolt::RewriteInstance::handleRelocation(llvm::object::SectionRef const&, llvm::object::RelocationRef const&)  /llvm/llvm-project/bolt/lib/Rewrite/RewriteInstance.cpp:3034:46
#13 0x000055cdd50c9df9 llvm::bolt::RewriteInstance::readRelocations(llvm::object::SectionRef const&)  /llvm/llvm-project/bolt/lib/Rewrite/RewriteInstance.cpp:2677:55
#14 0x000055cdd50c8443 llvm::bolt::RewriteInstance::processRelocations()  /llvm/llvm-project/bolt/lib/Rewrite/RewriteInstance.cpp:2484:20
#15 0x000055cdd50c1a4f llvm::bolt::RewriteInstance::discoverFileObjects()  /llvm/llvm-project/bolt/lib/Rewrite/RewriteInstance.cpp:1376:20
#16 0x000055cdd50bd6f2 llvm::bolt::RewriteInstance::run()  /llvm/llvm-project/bolt/lib/Rewrite/RewriteInstance.cpp:740:32
#17 0x000055cdd3d22b8a main  /llvm/llvm-project/bolt/tools/driver/llvm-bolt.cpp:267:29
#18 0x000014d25b236d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#19 0x000014d25b236e40 call_init ./csu/../csu/libc-start.c:128:20
#20 0x000014d25b236e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#21 0x000055cdd3d215a5 _start (bin/llvm-bolt+0x2ac5a5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BOLTcrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions