mfleming / performance-tools

A collection of performance-related tools and scripts
Apache License 2.0
67 stars 5 forks source link

BPF import error #1

Open schwarzschild-radius opened 4 years ago

schwarzschild-radius commented 4 years ago

I am getting the following error while running schedtime. I remember following the instructions to install bcc.

Traceback (most recent call last):
  File "./schedtime", line 23, in <module>
    from bcc import BPF
ImportError: cannot import name BPF
mfleming commented 4 years ago

This is probably a path issue. Which version(s) of python do you have on your system and did the bcc package install to the correct place? You find bcc's installation directory with $(find /usr -name bcc -type d). You should see it somewhere like /usr/lib/python3/dist-packages/bcc.

stefanodoni commented 4 years ago

Yes: /usr/lib/python3/dist-packages/bcc

schwarzschild-radius commented 4 years ago

I have both python2 and python3. I installed bcc using pip2(python2). I am still getting the same error. I also tried with python3 but the same result. There is a similar issue in another repo : https://github.com/iovisor/bcc/issues/2278

Is there a docker image?

stefanodoni commented 4 years ago

I have solved by installing python bpf package.

I now get a Segmentation Fault though...

On Sat, Feb 8, 2020, 20:42 Pradeep Kumar notifications@github.com wrote:

I have both python2 and python3. I installed bcc using pip2(python2). I am still getting the same error. I also tried with python3 but the same result. There is a similar issue in another repo : iovisor/bcc#2278 https://github.com/iovisor/bcc/issues/2278

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mfleming/performance-tools/issues/1?email_source=notifications&email_token=ADUHJFKWLRNFMKTDVUB27GTRB6CULA5CNFSM4KRINRP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELGCLAI#issuecomment-583804289, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUHJFNMPPPQXZV5DPT3IX3RB6CULANCNFSM4KRINRPQ .

mfleming commented 4 years ago

I have both python2 and python3. I installed bcc using pip2(python2). I am still getting the same error. I also tried with python3 but the same result. There is a similar issue in another repo : iovisor/bcc#2278

Is there a docker image?

There's no docker image, I'm afraid.

BCC isn't available in pip, and https://pypi.org/project/bcc/ has nothing to do with BPF so you're going to need to install the python-bcc package from your distribution or build it from source.

mfleming commented 4 years ago

I now get a Segmentation Fault though...

Can you use gdb to get a stacktrace to see why it's segfaulting?

stefanodoni commented 4 years ago

Sure,

not using gdb since ages, can you remind me how to do it?

On Thu, 13 Feb 2020 at 14:38, Matt Fleming notifications@github.com wrote:

I now get a Segmentation Fault though...

Can you use gdb to get a stacktrace to see why it's segfaulting?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mfleming/performance-tools/issues/1?email_source=notifications&email_token=ADUHJFNY3BGZDWA43FYQBN3RCVEMBA5CNFSM4KRINRP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELU7H4Y#issuecomment-585757683, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUHJFOGXN2VKLHUSE4BQVTRCVEMBANCNFSM4KRINRPQ .

-- Stefano Doni CTO at Akamas Mobile: +39-348-9691385 | E-mail: stefano.doni@akamas.io luca.forni@akamas.io www.akamas.io http://www.akamas.io/ | www.moviri.com http://www.moviri.com/

mfleming commented 4 years ago

$ gdb \<path to schedtime> (gdb) run \<whatever schedtime args cause the segfault> HIT SEGFAULT (gdb) bt

stefanodoni commented 4 years ago

Sorry for the late reply - I can't get the stacktrace:

$ sudo gdb ./schedtime ... "/home/.../performance-tools/./schedtime": not in executable format: File format not recognized (gdb) run ls Starting program: ls No executable file specified. Use the "file" or "exec-file" command.

Any hint?

mfleming commented 4 years ago

Sorry, try:

$ sudo gdb python (gdb) run ./schedtime

stefanodoni commented 4 years ago

(gdb) run ./schedtime ls Starting program: /usr/bin/python ./schedtime ls [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62 62 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory. (gdb) bt

0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62

1 0x00007ffff553d40d in ?? () from /usr/lib/x86_64-linux-gnu/libbcc.so.0

2 0x00007ffff55405f3 in bpf_object.open_xattr () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

3 0x00007ffff554451d in bpf_prog_load_xattr () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

4 0x00007ffff55446f0 in bpf_prog_load () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

5 0x00007ffff66bedae in ffi_call_unix64 () from

/usr/lib/x86_64-linux-gnu/libffi.so.6

6 0x00007ffff66be71f in ffi_call () from

/usr/lib/x86_64-linux-gnu/libffi.so.6

7 0x00007ffff68d24ba in _ctypes_callproc () from

/usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so

8 0x00007ffff68d16c5 in ?? () from /usr/lib/python2.7/lib-dynload/_

ctypes.x86_64-linux-gnu.so

9 0x000055555564de00 in PyEval_EvalFrameEx ()

10 0x000055555564661a in PyEval_EvalCodeEx ()

11 0x000055555564e612 in PyEval_EvalFrameEx ()

12 0x000055555564661a in PyEval_EvalCodeEx ()

13 0x000055555564dffe in PyEval_EvalFrameEx ()

14 0x000055555564661a in PyEval_EvalCodeEx ()

15 0x0000555555645f39 in PyEval_EvalCode ()

16 0x000055555567704f in ?? ()

17 0x0000555555672292 in PyRun_FileExFlags ()

18 0x0000555555671cbd in PyRun_SimpleFileExFlags ()

19 0x00005555556203e6 in Py_Main ()

20 0x00007ffff7a05b97 in __libc_start_main (main=0x55555561fdc0
,

argc=3, argv=0x7fffffffe4d8, init=, fini=, rtld_fini=, stack_end=0x7fffffffe4c8) at ../csu/libc-start.c:310

21 0x000055555561fcda in _start ()

On Wed, 11 Mar 2020 at 17:44, Matt Fleming notifications@github.com wrote:

Sorry, try:

$ sudo gdb python (gdb) run ./schedtime

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mfleming/performance-tools/issues/1#issuecomment-597742218, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUHJFOZBQDAHCCYMTLBVH3RG65XLANCNFSM4KRINRPQ .

-- Stefano Doni CTO at Akamas Mobile: +39-348-9691385 | E-mail: stefano.doni@akamas.io luca.forni@akamas.io www.akamas.io http://www.akamas.io/ | www.moviri.com http://www.moviri.com/

mfleming commented 4 years ago

Which version of bcc are you running?

On Wed, 11 Mar, at 05:08:02PM, Stefano Doni wrote:

(gdb) run ./schedtime ls Starting program: /usr/bin/python ./schedtime ls [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62 62 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory. (gdb) bt

0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62

1 0x00007ffff553d40d in ?? () from /usr/lib/x86_64-linux-gnu/libbcc.so.0

2 0x00007ffff55405f3 in bpf_object.open_xattr () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

3 0x00007ffff554451d in bpf_prog_load_xattr () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

4 0x00007ffff55446f0 in bpf_prog_load () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

5 0x00007ffff66bedae in ffi_call_unix64 () from

/usr/lib/x86_64-linux-gnu/libffi.so.6

6 0x00007ffff66be71f in ffi_call () from

/usr/lib/x86_64-linux-gnu/libffi.so.6

7 0x00007ffff68d24ba in _ctypes_callproc () from

/usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so

8 0x00007ffff68d16c5 in ?? () from /usr/lib/python2.7/lib-dynload/_

ctypes.x86_64-linux-gnu.so

9 0x000055555564de00 in PyEval_EvalFrameEx ()

10 0x000055555564661a in PyEval_EvalCodeEx ()

11 0x000055555564e612 in PyEval_EvalFrameEx ()

12 0x000055555564661a in PyEval_EvalCodeEx ()

13 0x000055555564dffe in PyEval_EvalFrameEx ()

14 0x000055555564661a in PyEval_EvalCodeEx ()

15 0x0000555555645f39 in PyEval_EvalCode ()

16 0x000055555567704f in ?? ()

17 0x0000555555672292 in PyRun_FileExFlags ()

18 0x0000555555671cbd in PyRun_SimpleFileExFlags ()

19 0x00005555556203e6 in Py_Main ()

20 0x00007ffff7a05b97 in __libc_start_main (main=0x55555561fdc0
,

argc=3, argv=0x7fffffffe4d8, init=, fini=, rtld_fini=, stack_end=0x7fffffffe4c8) at ../csu/libc-start.c:310

21 0x000055555561fcda in _start ()

On Wed, 11 Mar 2020 at 17:44, Matt Fleming notifications@github.com wrote:

Sorry, try:

$ sudo gdb python (gdb) run ./schedtime

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mfleming/performance-tools/issues/1#issuecomment-597742218, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUHJFOZBQDAHCCYMTLBVH3RG65XLANCNFSM4KRINRPQ .

-- Stefano Doni CTO at Akamas Mobile: +39-348-9691385 | E-mail: stefano.doni@akamas.io luca.forni@akamas.io www.akamas.io http://www.akamas.io/ | www.moviri.com http://www.moviri.com/

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/mfleming/performance-tools/issues/1#issuecomment-597754413

stefanodoni commented 4 years ago

I installed it from Ubuntu repos:

$ dpkg -l | grep bpf ii bpfcc-tools 0.13.0-0+bionic1 all tools for BPF Compiler Collection (BCC) ii bpftrace 0.9.4-0+bionic1 amd64 high-level tracing language for Linux eBPF ii libbpfcc 0.13.0-0+bionic1 amd64 shared library for BPF Compiler Collection (BCC) ii python-bpfcc 0.5.0-5ubuntu1 all Python wrappers for BPF Compiler Collection (BCC) ii python3-bpfcc 0.13.0-0+bionic1 all Python 3 wrappers for BPF Compiler Collection (BCC)

On Thu, 12 Mar 2020 at 21:56, Matt Fleming notifications@github.com wrote:

Which version of bcc are you running?

On Wed, 11 Mar, at 05:08:02PM, Stefano Doni wrote:

(gdb) run ./schedtime ls Starting program: /usr/bin/python ./schedtime ls [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62 62 ../sysdeps/x86_64/multiarch/strlen-avx2.S: No such file or directory. (gdb) bt

0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62

1 0x00007ffff553d40d in ?? () from /usr/lib/x86_64-linux-gnu/libbcc.so.0

2 0x00007ffff55405f3 in bpf_object.open_xattr () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

3 0x00007ffff554451d in bpf_prog_load_xattr () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

4 0x00007ffff55446f0 in bpf_prog_load () from

/usr/lib/x86_64-linux-gnu/libbcc.so.0

5 0x00007ffff66bedae in ffi_call_unix64 () from

/usr/lib/x86_64-linux-gnu/libffi.so.6

6 0x00007ffff66be71f in ffi_call () from

/usr/lib/x86_64-linux-gnu/libffi.so.6

7 0x00007ffff68d24ba in _ctypes_callproc () from

/usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so

8 0x00007ffff68d16c5 in ?? () from /usr/lib/python2.7/lib-dynload/_

ctypes.x86_64-linux-gnu.so

9 0x000055555564de00 in PyEval_EvalFrameEx ()

10 0x000055555564661a in PyEval_EvalCodeEx ()

11 0x000055555564e612 in PyEval_EvalFrameEx ()

12 0x000055555564661a in PyEval_EvalCodeEx ()

13 0x000055555564dffe in PyEval_EvalFrameEx ()

14 0x000055555564661a in PyEval_EvalCodeEx ()

15 0x0000555555645f39 in PyEval_EvalCode ()

16 0x000055555567704f in ?? ()

17 0x0000555555672292 in PyRun_FileExFlags ()

18 0x0000555555671cbd in PyRun_SimpleFileExFlags ()

19 0x00005555556203e6 in Py_Main ()

20 0x00007ffff7a05b97 in __libc_start_main (main=0x55555561fdc0
,

argc=3, argv=0x7fffffffe4d8, init=, fini=, rtld_fini=, stack_end=0x7fffffffe4c8) at ../csu/libc-start.c:310

21 0x000055555561fcda in _start ()

On Wed, 11 Mar 2020 at 17:44, Matt Fleming notifications@github.com wrote:

Sorry, try:

$ sudo gdb python (gdb) run ./schedtime

— You are receiving this because you commented. Reply to this email directly, view it on GitHub < https://github.com/mfleming/performance-tools/issues/1#issuecomment-597742218 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/ADUHJFOZBQDAHCCYMTLBVH3RG65XLANCNFSM4KRINRPQ

.

-- Stefano Doni CTO at Akamas Mobile: +39-348-9691385 | E-mail: stefano.doni@akamas.io luca.forni@akamas.io www.akamas.io http://www.akamas.io/ | www.moviri.com http://www.moviri.com/

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub:

https://github.com/mfleming/performance-tools/issues/1#issuecomment-597754413

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mfleming/performance-tools/issues/1#issuecomment-598414596, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADUHJFOCQPASTKPTQKHMZEDRHFEAZANCNFSM4KRINRPQ .

-- Stefano Doni CTO at Akamas Mobile: +39-348-9691385 | E-mail: stefano.doni@akamas.io luca.forni@akamas.io www.akamas.io http://www.akamas.io/ | www.moviri.com http://www.moviri.com/

stefanodoni commented 4 years ago

Hi @mfleming

Any news on the BCC error?

Thank you!

mfleming commented 11 months ago

@stefanodoni are you still hitting this error?