Bug 1636293

Summary: type mismatch error in pythonflow
Product: [Fedora] Fedora Reporter: Kazuo Moriwaka <kmoriwak>
Component: bccAssignee: Jiri Olsa <jolsa>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 28CC: jolsa, rdossant, skozina
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 0.7.0-2 bcc-0.7.0-2.fc28 bcc-0.7.0-2.fc29 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1637515 (view as bug list) Environment:
Last Closed: 2018-10-20 23:51:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1637515    

Description Kazuo Moriwaka 2018-10-05 02:33:42 UTC
Description of problem:

When pythonflow output traces, TypeError happens.


Version-Release number of selected component (if applicable):

bcc-0.6.1-2.fc28.x86_64
bcc-doc-0.6.1-2.fc28.noarch
python3-bcc-0.6.1-2.fc28.x86_64
bcc-lua-0.6.1-2.fc28.x86_64
bcc-tools-0.6.1-2.fc28.x86_64


How reproducible:

Always


Steps to Reproduce:
1. $ python
2. $ sudo /usr/share/bcc/tools/pythonflow <PID>
3. type Enter in python REPL

Actual results:

$ sudo ./pythonflow -C '<stdin>' 26904
Tracing method calls in python process 26904... Ctrl-C to quit.
CPU PID    TID    TIME(us) METHOD
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 234, in 'calling callback function'
  File "/usr/lib/python3.6/site-packages/bcc/table.py", line 572, in raw_cb_
    callback(cpu, data, size)
  File "./lib/uflow", line 187, in print_event
    ("  " * (depth - 1)) + direction + event.clazz + "." + event.method))
TypeError: must be str, not bytes

(and this traceback repeats)

Expected results:

$ sudo ./pythonflow -C '<stdin>' 27058
Tracing method calls in python process 27058... Ctrl-C to quit.
CPU PID    TID    TIME(us) METHOD
3   27058  27058  3.246    -> b'<stdin>'.b'<module>'               
3   27058  27058  3.246    -> b'<stdin>'.b'<module>'               

Additional info:

In lib/uflow's print_event function, event.clazz and event.method are bytes.
Putting str() for casting works. 

    print("%-3d %-6d %-6d %-8.3f %-40s" % (cpu, event.pid >> 32,
        event.pid & 0xFFFFFFFF, time.time() - start_ts,
        ("  " * (depth - 1)) + direction + str(event.clazz) + "." + str(event.method)))

ctypes.cast maps char * into bytes in python3.  
I expect this problem was caused by Python 2/3 difference, and some other tools have similar problems.

Comment 1 Rafael Fonseca 2018-10-05 08:24:30 UTC
Does it still happen with bcc-0.7.0?

Comment 2 Kazuo Moriwaka 2018-10-05 09:13:27 UTC
Yes, I reproduced with bcc-0.7.0-1 package.

rpm -qa|grep bcc
bcc-tools-0.7.0-1.fc28.x86_64
bcc-0.7.0-1.fc28.x86_64
python3-bcc-0.7.0-1.fc28.x86_64


# ./pythonflow 8887
Tracing method calls in python process 8887... Ctrl-C to quit.
CPU PID    TID    TIME(us) METHOD
Traceback (most recent call last):
  File "_ctypes/callbacks.c", line 234, in 'calling callback function'
  File "/usr/lib/python3.6/site-packages/bcc/table.py", line 572, in raw_cb_
    callback(cpu, data, size)
  File "./lib/uflow", line 194, in print_event
    ("  " * (depth - 1)) + direction + event.clazz + "." + event.method))
TypeError: must be str, not bytes

Comment 3 Rafael Fonseca 2018-10-05 11:13:03 UTC
Thank you. I reported it upstream https://github.com/iovisor/bcc/issues/1996.

Comment 4 Rafael Fonseca 2018-10-06 08:50:04 UTC
A patch was merged upstream. I'm going to submit new builds with the fix.

Comment 5 Fedora Update System 2018-10-06 08:57:18 UTC
bcc-0.7.0-2.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2018-dbf899e111

Comment 6 Fedora Update System 2018-10-06 09:11:32 UTC
bcc-0.7.0-2.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-a7443c7234

Comment 7 Fedora Update System 2018-10-07 23:36:42 UTC
bcc-0.7.0-2.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-dbf899e111

Comment 8 Fedora Update System 2018-10-08 00:09:11 UTC
bcc-0.7.0-2.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-a7443c7234

Comment 9 Kazuo Moriwaka 2018-10-09 04:42:07 UTC
Thank you for your super-fast fixing!
I verified the new package works.

Comment 10 Fedora Update System 2018-10-20 23:51:23 UTC
bcc-0.7.0-2.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.

Comment 11 Fedora Update System 2018-10-30 17:21:13 UTC
bcc-0.7.0-2.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report.