BOLT icon indicating copy to clipboard operation
BOLT copied to clipboard

[Instrumentation] PIC jump table heuristic failure

Open kmod opened this issue 5 years ago • 6 comments

Running bolt on jemalloc gives me an error:

$ sudo apt-get install libjemalloc-dev
$ llvm-bolt /usr/lib/x86_64-linux-gnu/libjemalloc.so -instrument -instrumentation-file-append-pid -instrumentation-file=/dev/null -o /dev/null
BOLT-INFO: Target architecture: x86_64
BOLT-INFO: BOLT version: f137ed238db11440f03083b1c88b7ffc0f4af65e
BOLT-INFO: shared object or position-independent executable detected
BOLT-INFO: first alloc address is 0x0
BOLT-INFO: creating new program header table at address 0x400000, offset 0x400000
BOLT-INFO: disabling -align-macro-fusion in non-relocation mode
BOLT-INFO: enabling lite mode
__BOLT_FDE_FUNCat68120
llvm-bolt: /home/kmod/nitrous/bolt/llvm/tools/llvm-bolt/src/BinaryFunction.cpp:864: llvm::bolt::IndirectBranchType llvm::bolt::BinaryFunction::processIndirect
Branch(llvm::MCInst&, unsigned int, uint64_t, uint64_t&): Assertion `MemType == MemoryContentsType::POSSIBLE_PIC_JUMP_TABLE && "PIC jump table heuristic failu
re"' failed.
bolt/build/bin/llvm-bolt(+0xc55aee)[0x55ff2ce61aee]
bolt/build/bin/llvm-bolt(+0xc53806)[0x55ff2ce5f806]
bolt/build/bin/llvm-bolt(+0xc53aca)[0x55ff2ce5faca]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f4cc56cd3c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f4cc516d18b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f4cc514c859]
/lib/x86_64-linux-gnu/libc.so.6(+0x25729)[0x7f4cc514c729]
/lib/x86_64-linux-gnu/libc.so.6(+0x36f36)[0x7f4cc515df36]
bolt/build/bin/llvm-bolt(+0x1ce50b)[0x55ff2c3da50b]
bolt/build/bin/llvm-bolt(+0x1d40bb)[0x55ff2c3e00bb]
bolt/build/bin/llvm-bolt(+0x2644c8)[0x55ff2c4704c8]
bolt/build/bin/llvm-bolt(+0x2beb57)[0x55ff2c4cab57]
bolt/build/bin/llvm-bolt(+0x14ffa2)[0x55ff2c35bfa2]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f4cc514e0b3]
bolt/build/bin/llvm-bolt(+0x18f58e)[0x55ff2c39b58e]
Stack dump:
0.      Program arguments: bolt/build/bin/llvm-bolt /usr/lib/x86_64-linux-gnu/libjemalloc.so -instrument -instrumentation-file-append-pid -instrumentation-fil
e=/dev/null -o /dev/null 
[1]    105627 abort (core dumped)  bolt/build/bin/llvm-bolt /usr/lib/x86_64-linux-gnu/libjemalloc.so -instrument

In my real workflow I link jemalloc statically and then run bolt on the final binary, but it looks like running bolt on libjemalloc.so is a smaller reproducer.

kmod avatar Mar 12 '21 18:03 kmod

Thanks for the report. We optimize binaries linked with jemalloc too, but we rely on LBR samples instead of instrumentation. I would recommend that, as the instrumentation pass still has some work to be done to be at the same level of maturity.

rafaelauler avatar Mar 12 '21 23:03 rafaelauler

Ah ok great to know. We switched from LBR to instrumentation so that we could run on AMD processors and EC2 instances and have generally been happy with it, but maybe we'll add back an LBR mode to our build.

kmod avatar Mar 16 '21 01:03 kmod

Do you get the same failure without instrumentation too? I was able to repro on libjemalloc.so and the reason is the presence of split functions in the library that comes with the distribution. At the moment, our level of support for split functions is limited and I recommend either building libjemalloc yourself with -fno-reorder-blocks-and-partition flag or linking your main app against libjemalloc.so dynamically.

maksfb avatar Mar 16 '21 08:03 maksfb

I couldn't figure out how to link jemalloc dynamically without resorting to LD_PRELOAD (lto somehow interferes with the standard override process), which is why I tried to link it statically. I forgot about that compilation flag, I'll try again by building jemalloc ourselves, thanks!

kmod avatar Mar 16 '21 17:03 kmod

@kmod: did you have success with manually-build libjemalloc without split functions?

aaupov avatar May 11 '21 06:05 aaupov

Sorry, I haven't tried it yet

kmod avatar May 11 '21 14:05 kmod

Closing since this is a library with split functions and stripped symbols, and BOLT does not support that.

aaupov avatar Mar 11 '23 01:03 aaupov