Bug 216896 - trace-cmd report -R breaks some int fields
Summary: trace-cmd report -R breaks some int fields
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: Trace-cmd/Kernelshark (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Default virtual assignee for Trace-cmd and kernelshark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-06 13:49 UTC by Douglas RAILLARD
Modified: 2023-01-09 10:15 UTC (History)
1 user (show)

See Also:
Kernel Version: N/A
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Use data size instead of field size to see if field falls out of bounds (428 bytes, patch)
2023-01-06 19:03 UTC, Steven Rostedt
Details | Diff

Description Douglas RAILLARD 2023-01-06 13:49:03 UTC
The latest tagged release of libtraceevent/libtracefs/trace-cmd leads to a broken -R output:

    git clone git://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git
    git -C trace-cmd checkout trace-cmd-v3.1.5

    git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git
    git -C libtraceevent checkout libtraceevent-1.7.0

    git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git
    git -C libtracefs checkout libtracefs-1.6.3


Built on Alpine with musl libc to make that static binary:
https://github.com/ARM-software/lisa/raw/d05e8efa46e10165a2b1526a89210ae1473859a8/lisa/_assets/binaries/x86_64/trace-cmd

The test trace (trace.dat v6 AFAIR) is available at: https://github.com/ARM-software/lisa/raw/d05e8efa46e10165a2b1526a89210ae1473859a8/doc/traces/trace.dat

    $ trace-cmd report trace.dat

          <idle>-0     [000]   470.783794: sched_switch:         prev_comm=swapper/0 prev_pid=0 prev_prio=120 prev_state=R ==> next_comm=sshd next_pid=3807 next_prio=120

    $ trace-cmd report -R trace.dat

          <idle>-0     [000]   470.783794: sched_switch:          prev_comm=swapper/0 prev_pid=0 prev_prio=0 prev_state=0 next_comm=sshd next_pid=0 next_prio=0

Note prev_pid and next_pid both equal to 0 in the raw format output. This seems to happen with all integer fields.
Comment 1 Douglas RAILLARD 2023-01-06 14:08:05 UTC
I bisected it to commit libtraceevent commit 
    
    efd32896dd5dbcaf72927dc07102fc359f6bdd6e
    libtraceevent: Add warnings if fields are outside the event

Compared to the old version of libtraceevent I was using, it still differs in display style (decimal instead of hex) but otherwise seems to be working.
Comment 2 Steven Rostedt 2023-01-06 19:03:09 UTC
Created attachment 303539 [details]
Use data size instead of field size to see if field falls out of bounds

Can you test this patch. But debugging this, I think this could be optimized a bit as well. But that's another story.
Comment 4 Douglas RAILLARD 2023-01-09 10:15:21 UTC
That seems to have fixed the issue, thanks !

Note You need to log in before you can comment on or make changes to this bug.