Open joebonrichie opened 1 month ago
bughunter
$ BOLT=./stage1/install/bin/llvm-bolt BOLT_OPTIONS="-v=1" INPUT_BINARY=./stage1/install/lib/libclang-cpp.so.20.0git bolt/utils/bughunter.sh
Verify input binary passes
INPUT_BINARY: : && ./stage1/install/lib/libclang-cpp.so.20.0git |& cat >& /tmp/libclang-cpp.so.20.0git.3tX.bolt.out
bolt/utils/bughunter.sh: line 97: 698665 Segmentation fault (core dumped) $TIMEOUT_OR_CMD $INPUT_BINARY $COMMAND_LINE 2>&1
698666 Done | $POST_COMMAND >&$OUTPUT_FILE
Warning: input binary failed
Verify optimized binary fails
Bolt crashes while generating optimized binary.
egrep: warning: egrep is obsolescent; using grep -E
egrep: warning: egrep is obsolescent; using grep -E
Iteration 0, trying /tmp/func-names.eiR.txtaa / 56983 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.eiR.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 1, trying /tmp/func-names.rJG.txtaa / 28492 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.rJG.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 2, trying /tmp/func-names.9rf.txtaa / 14246 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.9rf.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 3, trying /tmp/func-names.OOh.txtaa / 7123 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.OOh.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 4, trying /tmp/func-names.Emo.txtaa / 3562 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.Emo.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 5, trying /tmp/func-names.Cc6.txtaa / 1781 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.Cc6.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 6, trying /tmp/func-names.yo9.txtaa / 891 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.yo9.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 7, trying /tmp/func-names.xZG.txtaa / 446 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.xZG.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 8, trying /tmp/func-names.ZjP.txtaa / 223 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.ZjP.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 9, trying /tmp/func-names.hOm.txtaa / 112 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.hOm.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 10, trying /tmp/func-names.6Gf.txtaa / 56 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.6Gf.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 11, trying /tmp/func-names.Wrg.txtaa / 28 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.Wrg.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 12, trying /tmp/func-names.NdQ.txtaa / 14 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.NdQ.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 13, trying /tmp/func-names.hPG.txtaa / 7 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.hPG.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 14, trying /tmp/func-names.2dz.txtaa / 4 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.2dz.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 15, trying /tmp/func-names.YxM.txtaa / 2 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.YxM.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
Iteration 16, trying /tmp/func-names.Zte.txtaa / 1 functions
BOLT: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.Zte.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt >& /tmp/bolt3A4.log
BOLT failure=1
The function(s) that failed are in /tmp/func-names.xv2.txtaa
To reproduce, run: ./stage1/install/bin/llvm-bolt -v=1 ./stage1/install/lib/libclang-cpp.so.20.0git -funcs-file-no-regex=/tmp/func-names.Zte.txtaa -o /tmp/libclang-cpp.so.20.0git.3tX.bolt
rm: cannot remove '/tmp/libclang-cpp.so.20.0git.3tX.bolt': No such file or directory
rm: cannot remove '/tmp/libclang-cpp.so.20.0git.3tX.bolt.out': No such file or directory
[ble: exit 1]
$ cat /tmp/func-names.xv2.txtaa -p
__bolt_fini_trampoline
bisected to https://github.com/llvm/llvm-project/commit/0053cb8ef0a13b444bea598159f873fade200367
partial revert of 0053cb8ef0a13b444bea598159f873fade200367 fixes clang segfaulting after libclang/libLLVM has been instrumented
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 32ec7abe8b66..f7f63b2ea956 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -5068,11 +5068,9 @@ void RewriteInstance::patchELFAllocatableRelrSection(
const uint8_t PSize = BC->AsmInfo->getCodePointerSize();
const uint64_t MaxDelta = ((CHAR_BIT * DynamicRelrEntrySize) - 1) * PSize;
- auto FixAddend = [&](const BinarySection &Section, const Relocation &Rel,
- uint64_t FileOffset) {
+ auto FixAddend = [&](const BinarySection &Section, const Relocation &Rel) {
// Fix relocation symbol value in place if no static relocation found
- // on the same address. We won't check the BF relocations here since it
- // is rare case and no optimization is required.
+ // on the same address
if (Section.getRelocationAt(Rel.Offset))
return;
@@ -5081,6 +5079,10 @@ void RewriteInstance::patchELFAllocatableRelrSection(
if (!Addend)
return;
+ uint64_t FileOffset = Section.getOutputFileOffset();
+ if (!FileOffset)
+ FileOffset = Section.getInputFileOffset();
+ FileOffset += Rel.Offset;
OS.pwrite(reinterpret_cast<const char *>(&Addend), PSize, FileOffset);
};
@@ -5102,7 +5104,7 @@ void RewriteInstance::patchELFAllocatableRelrSection(
RelOffset = RelOffset == 0 ? SectionAddress + Rel.Offset : RelOffset;
assert((RelOffset & 1) == 0 && "Wrong relocation offset");
RelOffsets.emplace(RelOffset);
- FixAddend(Section, Rel, RelOffset);
+ FixAddend(Section, Rel);
}
}
--
@yota9 hopefully you don't mind the ping
Tested as of db1a76206902e6926464e30cc47249e217405dab, the last worked was with llvm-17
Repro:
backstrace
Lemme know if I can provide any more details.