Misaligned reads, stores and accesses with LV2 atoms (fifths and midigate)
Building the example plugins using
clang -fno-omit-frame-pointer -g -fsanitize=undefined -shared-libasan <plugin>.c -shared -fPIC -o <plugin>.so
and then running the plugin in either either Carla or Ardour with:
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 0x555558ad5cac for type 'LV2_Atom_Event', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 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 0x555558ad5cb4 for type 'LV2_Atom', which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
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 0x555558ad5cac for type 'const LV2_Atom_Event', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 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 0x555558ad5cb4 for type 'const LV2_Atom', which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
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 0x555558ad5cb4 for type 'const uint32_t' (aka 'const unsigned int'), which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
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 0x555558addcec for type 'LV2_Atom_Event *', which requires 8 byte alignment
0x555558addcec: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:177:10
/usr/include/lv2/atom/util.h:177:13: runtime error: load of misaligned address 0x555558ad5cac for type 'const LV2_Atom_Event *', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:177:13
src/eg-fifths.lv2/fifths.c:116:41: runtime error: member access within misaligned address 0x555558ad5cac for type 'LV2_Atom_Event', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:116:41
src/eg-fifths.lv2/fifths.c:116:41: runtime error: member access within misaligned address 0x555558ad5cac for type 'union (unnamed union at /usr/include/lv2/atom/atom.h:216:3)', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:116:41
src/eg-fifths.lv2/fifths.c:116:46: runtime error: load of misaligned address 0x555558ad5cac for type 'int64_t' (aka 'long'), which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:116:46
src/eg-fifths.lv2/fifths.c:117:39: runtime error: member access within misaligned address 0x555558ad5cac for type 'LV2_Atom_Event', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:117:39
src/eg-fifths.lv2/fifths.c:117:39: runtime error: member access within misaligned address 0x555558ad5cb4 for type 'LV2_Atom', which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:117:39
src/eg-fifths.lv2/fifths.c:118:39: runtime error: member access within misaligned address 0x555558ad5cac for type 'LV2_Atom_Event', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:118:39
src/eg-fifths.lv2/fifths.c:118:39: runtime error: member access within misaligned address 0x555558ad5cb4 for type 'LV2_Atom', which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:118:39
src/eg-fifths.lv2/fifths.c:118:44: runtime error: load of misaligned address 0x555558ad5cb4 for type 'uint32_t' (aka 'unsigned int'), which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/eg-fifths.lv2/fifths.c:118:44
/usr/include/lv2/atom/util.h:110:49: runtime error: member access within misaligned address 0x555558ad5cac for type 'const LV2_Atom_Event', which requires 8 byte alignment
0x555558ad5cac: note: pointer points here
00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:110:49
/usr/include/lv2/atom/util.h:110:49: runtime error: member access within misaligned address 0x555558ad5cb4 for type 'const LV2_Atom', which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:110:49
/usr/include/lv2/atom/util.h:110:54: runtime error: load of misaligned address 0x555558ad5cb4 for type 'const uint32_t' (aka 'const unsigned int'), which requires 8 byte alignment
0x555558ad5cb4: note: pointer points here
00 00 00 00 03 00 00 00 10 00 00 00 90 43 64 00 00 00 00 00 00 00 00 00 41 03 02 00 00 00 00 00
^
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/include/lv2/atom/util.h:110:54