Skip to content

Commit

Permalink
pipewire: module-profiler: fix misaligned access
Browse files Browse the repository at this point in the history
Fix the following misaligned access that happens when `pw-top` is started:

  ../src/modules/module-profiler.c:144:5: runtime error: member access within misaligned address 0x7f7fa11fe8d9 for type 'struct spa_pod_struct', which requires 4 byte alignment
  0x7f7fa11fe8d9: note: pointer points here
   60 00 00  01 00 00 00 00 00 00 00  00 88 02 00 00 0f 00 00  00 0a 00 04 00 00 00 00  00 01 00 01 00
                ^
      #0 0x7f7fa64a65e1 in do_flush_event ../src/modules/module-profiler.c:144
      #1 0x7f7fa36d658e in source_event_func ../spa/plugins/support/loop.c:650
      #2 0x7f7fa36cfbab in loop_iterate ../spa/plugins/support/loop.c:483
      #3 0x7f7fa80a71cd in pw_main_loop_run ../src/pipewire/main-loop.c:128
      #4 0x55af46ff4722 in main ../src/daemon/pipewire.c:111
      #5 0x7f7fa8a3984f  (/usr/lib/libc.so.6+0x2384f) (BuildId: 2f005a79cd1a8e385972f5a102f16adba414d75e)
      #6 0x7f7fa8a39909 in __libc_start_main (/usr/lib/libc.so.6+0x23909) (BuildId: 2f005a79cd1a8e385972f5a102f16adba414d75e)
      PipeWire#7 0x55af46ff32a4 in _start (src/daemon/pipewire+0x42a4) (BuildId: 2d6250e405f52fb86992fef8584ccfdfdb85569f)

  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/modules/module-profiler.c:144:5 in
  • Loading branch information
pobrn committed Aug 1, 2023
1 parent 5361293 commit 0cbcf88
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modules/module-profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <string.h>
#include <stdio.h>
#include <stdalign.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -103,6 +104,7 @@ struct impl {
struct spa_source *flush_event;
unsigned int listening:1;

alignas(max_align_t)
uint8_t flush[FLUSH_BUFFER + sizeof(struct spa_pod_struct)];
};

Expand Down

0 comments on commit 0cbcf88

Please sign in to comment.