bcc icon indicating copy to clipboard operation
bcc copied to clipboard

AttributeError: 'PerfEventArray' object has no attribute 'event' Error

Open Juntaran opened this issue 7 years ago • 7 comments

juntaran@ubuntu:~/workspace/kernel/bcc/tools$ sudo ./execsnoop.py 
PCOMM            PID    PPID   RET ARGS
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 315, in 'calling callback function'
  File "/usr/lib/python2.7/dist-packages/bcc/table.py", line 572, in raw_cb_
    callback(cpu, data, size)
  File "./execsnoop.py", line 198, in print_event
    event = b["events"].event(data)
AttributeError: 'PerfEventArray' object has no attribute 'event'
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 315, in 'calling callback function'
  File "/usr/lib/python2.7/dist-packages/bcc/table.py", line 572, in raw_cb_
    callback(cpu, data, size)
  File "./execsnoop.py", line 198, in print_event
    event = b["events"].event(data)
AttributeError: 'PerfEventArray' object has no attribute 'event'
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 315, in 'calling callback function'
  File "/usr/lib/python2.7/dist-packages/bcc/table.py", line 572, in raw_cb_
    callback(cpu, data, size)
  File "./execsnoop.py", line 198, in print_event
    event = b["events"].event(data)
AttributeError: 'PerfEventArray' object has no attribute 'event'

sudo ./execsnoop.py except execsnoop and some other python script have same error

How i fix:

git reset --hard 75a1f3d051138dbc00a67d17ddad938c83f13f00

in commit 51d62d36bd072530a238ac147a61b631fdc44659

commit 51d62d36bd072530a238ac147a61b631fdc44659
Author: Xiaozhou Liu <[email protected]>
Date:   Fri Feb 15 13:03:05 2019 +0800

    tools: remove redundant Python event data structure definitions (#2204)
    
    Simplify code following #2198 (https://github.com/iovisor/bcc/pull/2198).
    
    Some tools are not touched: mountsnoop.py, trace.py, lib/*.py, old/*.py.

maybe 51d62d36bd072530a238ac147a61b631fdc44659 this commit caused it

Juntaran avatar Feb 24 '19 18:02 Juntaran

@boat0

Juntaran avatar Feb 24 '19 18:02 Juntaran

I guess your versions of installed libbcc and tools do not match.

boat0 avatar Feb 25 '19 04:02 boat0

I guess your versions of installed libbcc and tools do not match.

image they are same version

Juntaran avatar Mar 01 '19 10:03 Juntaran

@Juntaran So you installed bcc from sources? If you installed bcc from packages and are running execsnoop.py from this repository, then they probably don't have the same version. Install bcc from sources or run the execsnoop executable provided with the package.

pchaigno avatar Mar 01 '19 11:03 pchaigno

I see the problem: the libbcc installed is 0.6 while the tools you are actually using is 0.8+. Most likely you ran the tools from a git repo which is recently updated.

boat0 avatar Mar 01 '19 11:03 boat0

@Juntaran So you installed bcc from sources? If you installed bcc from packages and are running execsnoop.py from this repository, then they probably don't have the same version. Install bcc from sources or run the execsnoop executable provided with the package.

Hi
thanks for the reply, i use Ubuntu 18.10 and install as https://github.com/iovisor/bcc/blob/master/INSTALL.md sudo apt-get install bpfcc-tools linux-headers-$(uname -r)

I'll try install from source thank you again

Juntaran avatar Mar 04 '19 03:03 Juntaran

@Juntaran So you installed bcc from sources? If you installed bcc from packages and are running execsnoop.py from this repository, then they probably don't have the same version. Install bcc from sources or run the execsnoop executable provided with the package.

Hi thanks for the reply, i use Ubuntu 18.10 and install as https://github.com/iovisor/bcc/blob/master/INSTALL.md sudo apt-get install bpfcc-tools linux-headers-$(uname -r)

I'll try install from source thank you again

after install from source, the world is peace and everything is ok : ) 👍

Juntaran avatar Mar 04 '19 08:03 Juntaran