Skip to contentSkip to conversation

perf trace: Unaligned access in timespec

BUG Namhyung Kim 1 participant 1 message Dec 19, 2024

lore
Share & tools
lore
#0 lore raw

Hello,

I found perf trace is getting core dump due to illegal instruction by misaligned pointer access. It seems to come with the new clang changes and I got this UBsan message.

  $ sudo ./perf trace -a sleep 1
  ...
  tools/perf/trace/beauty/timespec.c:10:64: runtime error: member access within misaligned address
  					  0x7f57636105e4 for type 'struct augmented_arg',
  					  which requires 8 byte alignment
  0x7f57636105e4: note: pointer points here
    ad 7f 00 00 10 00 00 00  00 00 00 00 01 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
                ^ 
      #0 0x5637d68d0ed7 in syscall_arg__scnprintf_augmented_timespec tools/perf/trace/beauty/timespec.c:10:64
      #1 0x5637d68d0ed7 in syscall_arg__scnprintf_timespec tools/perf/trace/beauty/timespec.c:18:10
      #2 0x5637d688dfef in syscall_arg_fmt__scnprintf_val tools/perf/builtin-trace.c:2316:10
      #3 0x5637d688dfef in syscall__scnprintf_args tools/perf/builtin-trace.c:2394:15
      #4 0x5637d68838ee in trace__sys_enter tools/perf/builtin-trace.c:2675:13
      #5 0x5637d688ec8c in trace__handle_event tools/perf/builtin-trace.c:3495:3
      #6 0x5637d688ec8c in __trace__deliver_event tools/perf/builtin-trace.c:4045:3
      #7 0x5637d6886841 in trace__deliver_event tools/perf/builtin-trace.c:4072:10
      #8 0x5637d6886841 in trace__run tools/perf/builtin-trace.c:4432:10
      #9 0x5637d688112b in cmd_trace tools/perf/builtin-trace.c:5521:9
      #10 0x5637d67af002 in run_builtin tools/perf/perf.c:351:11
      #11 0x5637d67aee36 in handle_internal_command tools/perf/perf.c:404:8
      #12 0x5637d67ae76e in run_argv tools/perf/perf.c:448:2
      #13 0x5637d67ae76e in main tools/perf/perf.c:562:3
      #14 0x7f576498a3d3 in __libc_start_main (/usr/lib64/libc.so.6+0x613d3)
      #15 0x5637d6793f69 in _start /usr/src/csu/../sysdeps/x86_64/start.S:120

SUMMARY: UndefinedBehaviorSanitizer: misaligned-pointer-use tools/perf/trace/beauty/timespec.c:10:64

Thanks,
Namhyung