facebookarchive / BOLT

Binary Optimization and Layout Tool - A linux command-line utility used for optimizing performance of binaries
2.51k stars 176 forks source link

parseLSDA error with no warnings #211

Open mgrice opened 3 years ago

mgrice commented 3 years ago

compiling with gcc 7.3. Would that be a problem?

possibly important compile flags: -std=c++11 -fno-exceptions -fno-rtti -z noexecstack -fdata-sections -ffunction-sections -g -O3

PERF2BOLT: Starting data aggregation job for perfbolt.data PERF2BOLT: spawning perf job to read branch events PERF2BOLT: spawning perf job to read mem events PERF2BOLT: spawning perf job to read process events PERF2BOLT: spawning perf job to read task events BOLT-INFO: Target architecture: x86_64 BOLT-INFO: BOLT version: 09adc38a47fa86a26cbd4e7c2b94e0bb04da9c2e BOLT-INFO: first alloc address is 0x400000 BOLT-INFO: creating new program header table at address 0x3800000, offset 0x3400000 BOLT-INFO: disabling -align-macro-fusion in non-relocation mode BOLT-INFO: enabling lite mode BOLT-INFO: pre-processing profile using perf data aggregator BOLT-WARNING: build-id will not be checked because we could not read one from input binary PERF2BOLT: waiting for perf mmap events collection to finish... PERF2BOLT: parsing perf-script mmap events output PERF2BOLT: waiting for perf task events collection to finish... PERF2BOLT: parsing perf-script task events output PERF2BOLT: input binary is associated with 1 PID(s) PERF2BOLT: waiting for perf events collection to finish... PERF2BOLT: parse branch events... PERF2BOLT: read 1096727 samples and 35093599 LBR entries PERF2BOLT: 0 samples (0.0%) were ignored PERF2BOLT: traces mismatching disassembled function contents: 124072 (0.4%) PERF2BOLT: out of range traces involving unknown regions: 1014185 (3.0%) BOLT-INFO: forcing -jump-tables=move as PIC jump table was detected in function _ZN4llvm12InstCombiner13foldICmpBinOpERNS_8ICmpInstE/1 perf2bolt: /home/mgrice/oss/llvm-bolt/bolt/src/Exceptions.cpp:112: void llvm::bolt::BinaryFunction::parseLSDA(llvm::ArrayRef, uint64_t): Assertion `Data.isValidOffset(Offset) && "wrong LSDA address"' failed.

0 0x00005613a9c35cb3 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0

1 0x00005613a9c337ee SignalHandler(int) Signals.cpp:0:0

2 0x00007fb9e78c03c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)

3 0x00007fb9e735f18b raise /build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1

4 0x00007fb9e733e859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7

5 0x00007fb9e733e729 get_sysdep_segment_value /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8

6 0x00007fb9e733e729 _nl_load_domain /build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34

7 0x00007fb9e734ff36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)

8 0x00005613a8f462f9 llvm::bolt::BinaryFunction::parseLSDA(llvm::ArrayRef, unsigned long) (/home/mgrice/oss/llvm-bolt/build/bin/perf2bolt+0x2ce2f9)

9 0x00005613a8f702d2 llvm::bolt::RewriteInstance::disassembleFunctions() (/home/mgrice/oss/llvm-bolt/build/bin/perf2bolt+0x2f82d2)

10 0x00005613a8fc8ddf llvm::bolt::RewriteInstance::run() (/home/mgrice/oss/llvm-bolt/build/bin/perf2bolt+0x350ddf)

11 0x00005613a8e2e038 main (/home/mgrice/oss/llvm-bolt/build/bin/perf2bolt+0x1b6038)

12 0x00007fb9e73400b3 __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3

13 0x00005613a8e8327e _start (/home/mgrice/oss/llvm-bolt/build/bin/perf2bolt+0x20b27e)

PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.

yavtuk commented 2 years ago

Hi @mgrice, could you tell what did you try to process by bolt? when I faced the same issue the cause was in build environment and lsda field was incorrect in original binary. I used llvm-dwarfdump with -eh-frame option to get FDEs information and checked the address in Augmentation field with "L" value of CIEs

mgrice commented 2 years ago

Thanks for the info. It's a binary compiled with gcc 7.3. What was the cause of the incorrect LSDA fields in your case?

yavtuk commented 2 years ago

Yes, I had the binary compiled 7.3 as well, but I don’t know a cause because I asked to product team check and rebuild the one, after that the issue is gone.