LV2 atoms are misaligned
rantlivelintkale opened this issue · comments
Valtteri Kallinen commented
If the LV2 MIDI example plugins are built using:
clang -fno-omit-frame-pointer -g -fsanitize=undefined -shared-libasan <plugin>.c -shared -fPIC -o <plugin>.so
then running Carla using:
LD_PRELOAD=$(clang -print-file-name=libclang_rt.ubsan_standalone.so)
gives the following runtime errors:
src/eg-fifths.lv2/fifths.c:103:13: runtime error: member access within misaligned address 0x55555747058c for type 'LV2_Atom_Event', which requires 8 byte alignment
0x55555747058c: note: pointer points here
60 05 47 57 00 00 00 00 00 00 00 00 03 00 00 00 2f 00 00 00 90 4a 64 00 11 00 00 00 08 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:103:13
src/eg-fifths.lv2/fifths.c:103:13: runtime error: member access within misaligned address 0x555557470594 for type 'LV2_Atom', which requires 8 byte alignment
0x555557470594: note: pointer points here
00 00 00 00 03 00 00 00 2f 00 00 00 90 4a 64 00 11 00 00 00 08 00 00 00 70 69 70 65 77 69 72 65
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:103:13
/usr/include/lv2/atom/util.h:171:65: runtime error: member access within misaligned address 0x55555747058c for type 'const LV2_Atom_Event', which requires 8 byte alignment
0x55555747058c: note: pointer points here
60 05 47 57 00 00 00 00 00 00 00 00 03 00 00 00 2f 00 00 00 90 4a 64 00 11 00 00 00 08 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:171:65
/usr/include/lv2/atom/util.h:171:65: runtime error: member access within misaligned address 0x555557470594 for type 'const LV2_Atom', which requires 8 byte alignment
0x555557470594: note: pointer points here
00 00 00 00 03 00 00 00 2f 00 00 00 90 4a 64 00 11 00 00 00 08 00 00 00 70 69 70 65 77 69 72 65
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:171:65
/usr/include/lv2/atom/util.h:171:70: runtime error: load of misaligned address 0x555557470594 for type 'const uint32_t' (aka 'const unsigned int'), which requires 8 byte alignment
0x555557470594: note: pointer points here
00 00 00 00 03 00 00 00 2f 00 00 00 90 4a 64 00 11 00 00 00 08 00 00 00 70 69 70 65 77 69 72 65
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:171:70
/usr/include/lv2/atom/util.h:177:10: runtime error: store to misaligned address 0x55555747270c for type 'LV2_Atom_Event *', which requires 8 byte alignment
0x55555747270c: note: pointer points here
e0 26 47 57 55 55 00 00 3a 49 6e 74 65 72 66 61 63 65 3a 46 61 63 74 6f 72 79 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:177:10
The bug does not occur with Jalv or Reaper. The LV2 atoms should be 64-bit aligned.
http://lv2plug.in/ns/ext/atom#Atom
https://lv2plug.in/c/html/group__atom.html#structLV2__Atom__Sequence__Body