bcc: bcc does not pick the right libraries
bcc is not considering the encoded hwcap when choosing libraries. As such, uprobes on a shared library does not work on powerpc, as seen with the uprobes test:
======================================================================
FAIL: test_simple_library (__main__.TestUprobes)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/bcc/tests/python/test_uprobes.py", line 34, in test_simple_library
self.assertEqual(b["stats"][ctypes.c_int(0)].value, 2)
AssertionError: 0L != 2
----------------------------------------------------------------------
libc libraries in cache:
# ldconfig -p | grep libc.so
libc.so.6 (libc6,64bit, hwcap: 0x0000200000000000, OS ABI: Linux 2.6.32) => /lib64/power8/libc.so.6
libc.so.6 (libc6,64bit, OS ABI: Linux 2.6.32) => /lib64/libc.so.6
bcc always picks the first library here, which won’t work on non-power8 machines.
We need to either implement stricter checks (look at hwcap and perhaps the platform) or consider probing on all libraries with the same name.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 3
- Comments: 16 (6 by maintainers)
@pchaigno, Nice work on #875.
I just patched
tests/python/test_uprobes.py
to take advantage of it and got those tests to pass. I’ll submit a pull request with that, and a few other things soon…Hi @pchaigno which patches should be applied to make the test pass ? Right now on a Debian Jessie the build hangs on the py_uprobes test.
Just ran into this issue while building / testing on Debian 8 amd64.
Looks like
malloc_stats()
is missing from this distro and version.@rnav, would you mind doing the same check with python and
find_library()
on the host where you discovered this issue?Sure. It looks like @vmg wrote much of this code. @vmg do you have ideas on how best to address this?
Yes, thanks for explaining, that certainly makes more sense! Actually the problem seems obvious in retrospect but its been a busy morning so far 😃
Oh, I probably should have explained better. The problem actually shows up at runtime and not while building bcc itself. In this case, it is with test_uprobes.py:
In test_uprobes.py, we use the below line to place a probe at malloc_stats() in libc:
This triggers a search for libc, which on powerpc ends up picking the wrong library to place the probe (/lib64/power8/libc.so.6 rather than /lib64/libc.so.6). As such, the probe never fires.
The reason we pick the wrong library is because we are not considering the hwcap associated with the library.