Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbpf-tools: Fix llx printf modifiers in futexctn #4836

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

captain5050
Copy link
Contributor

Fix llx printf modifiers by using inttypes.h's PRIx64.

The perf buffer in exit snoop doesn't maintain 8 byte alignment for
start_time and exit_time in struct event. When building with
"-fsanitize=alignment -fsanitize-undefined-trap-on-error" failures
happen in handle_event. Fix these by copying the event from the perf
buffer before accessing.

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in biosnoop doesn't maintain 8 byte alignment for
delta, qdelta, ts and sector in struct event. When building with
"-fsanitize=alignment -fsanitize-trap=undefined" failures happen in
handle_event. Fix these by copying the event from the perf buffer
before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in filelife doesn't maintain 8 byte alignment for
delta_ns in struct event. When building with "-fsanitize=alignment
-fsanitize-trap=undefined" failures happen in handle_event. Fix these
by copying the event from the perf buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in fsslower doesn't maintain 8 byte alignment for
delta_us, end_ns, offset and size in struct event. When building with
"-fsanitize=alignment -fsanitize-trap=undefined" failures happen in
handle_event. Fix these by copying the event from the perf buffer
before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in gethostlatency doesn't maintain 8 byte alignment for
time in struct event. When building with "-fsanitize=alignment
 -fsanitize-trap=undefined" failures happen in
handle_event. Fix these by copying the event from the perf buffer
before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in opensnoop doesn't maintain 8 byte alignment
for ts and callers in struct event. When building with "
-fsanitize=alignment -fsanitize-trap=undefined" failures happen
in handle_event. Fix these by copying the event from the perf
buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in runqslower doesn't maintain 8 byte alignment
for delta_us in struct event. When building with "-fsanitize=alignment
 -fsanitize-trap=undefined" failures happen
in handle_event. Fix these by copying the event from the perf
buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in statsnoop doesn't maintain 8 byte alignment
for ts_ns in struct event. When building with "-fsanitize=alignment
 -fsanitize-trap=undefined" failures happen
in handle_event. Fix these by copying the event from the perf
buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in tcpconnect doesn't maintain 8 byte alignment
for ts_us in struct event. When building with "-fsanitize=alignment
 -fsanitize-trap=undefined" failures happen
in handle_event. Fix these by copying the event from the perf
buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in tcplife doesn't maintain 8 byte alignment
for saddr, daddr, ts_us, span_us, rx_b and tx_b in struct event.
 When building with "-fsanitize=alignment
 -fsanitize-trap=undefined" failures happen in handle_event.
Fix these by copying the event from the perf buffer before
accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in tcpstates doesn't maintain 8 byte alignment
for saddr, daddr, skaddr, ts_us and delta_us in struct event.
When building with "-fsanitize=alignment -fsanitize-trap=undefined"
failures happen in handle_event. Fix these by copying the event
from the perf buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in tcptracer doesn't maintain 8 byte alignment
for saddr_v4, daddr_v4 and ts_us in struct event.
When building with "-fsanitize=alignment -fsanitize-trap=undefined"
failures happen in handle_event. Fix these by copying the event
from the perf buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
The perf buffer in drsnoop doesn't maintain 8 byte alignment
for delta_ns, nr_reclaimed and nr_free_pages in struct event.
When building with "-fsanitize=alignment -fsanitize-trap=undefined"
failures happen in handle_event. Fix these by copying the event
from the perf buffer before accessing.

This is similar to a fix in exitsnoop where different ways to handle
misaligned pointers were discussed:
iovisor#4760

Signed-off-by: Ian Rogers <[email protected]>
Fix the following warning:
```
$ make futexctn
...
futexctn.c: In function ‘print_stack’:
futexctn.c:236:59: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
  236 |                                 printf("    #%-2d 0x%016llx [unknown]\n", idx++, ip[i]);
      |                                                     ~~~~~~^                      ~~~~~
      |                                                           |                        |
      |                                                           long long unsigned int   uint64_t {aka long unsigned int}
      |                                                     %016lx
futexctn.c:249:51: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
  249 |                         printf("    #%-2d 0x%016llx", idx++, ip[i]);
      |                                             ~~~~~~^          ~~~~~
      |                                                   |            |
      |                                                   |            uint64_t {aka long unsigned int}
      |                                                   long long unsigned int
      |                                             %016lx
...
```
by using inttypes.h.

Signed-off-by: Ian Rogers <[email protected]>
@yonghong-song
Copy link
Collaborator

In libbpf-tools/javagc.c, we already have

javagc.c:       while (fscanf(f, "%zx-%zx %s %zx %*s %*d%[^\n]\n",

So '%zx' should work in your case. To preserve the code consistency, could you use '%zx' style instead?

@yonghong-song
Copy link
Collaborator

BTW, this patch has conflict with latest futexctn.c. You need to rebase your patch on the top of latest master branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants