Is there an existing issue for the same bug?
Version or Commit ID
0.7.0
Other environment information
Actual behavior and How to reproduce it
Description:
When building with UndefinedBehaviorSanitizer (UBSAN), infinity fails to start with the following error:
runtime error: member access within misaligned address 0x7a4afc1e50a9
for type 'WalEntryHeader', which requires 8 byte alignment
Root Cause:
In WalEntry::ReadAdv(), the code uses reinterpret_cast to directly access the WAL entry header:
auto *header = reinterpret_cast<WalEntryHeader *>(const_cast<char *>(ptr));
Why it works on x86:
x86 CPUs can handle misaligned memory access (with performance penalty), so the bug doesn't manifest on x86_64. However:
Performance degradation on x86
Potential crashes on ARM
Risk of data corruption
Solution:
Use ReadBuf/ReadBufAdv and WriteBuf functions (which use memcpy) instead of direct struct access. These functions handle unaligned memory safely.
Files affected:
src/storage/wal/wal_entry_impl.cpp
Expected behavior
No response
Additional information
No response
Is there an existing issue for the same bug?
Version or Commit ID
0.7.0
Other environment information
Actual behavior and How to reproduce it
Description:
When building with UndefinedBehaviorSanitizer (UBSAN), infinity fails to start with the following error:
runtime error: member access within misaligned address 0x7a4afc1e50a9
for type 'WalEntryHeader', which requires 8 byte alignment
Root Cause:
In
WalEntry::ReadAdv(), the code usesreinterpret_castto directly access the WAL entry header:Why it works on x86:
x86 CPUs can handle misaligned memory access (with performance penalty), so the bug doesn't manifest on x86_64. However:
Performance degradation on x86
Potential crashes on ARM
Risk of data corruption
Solution:
Use ReadBuf/ReadBufAdv and WriteBuf functions (which use memcpy) instead of direct struct access. These functions handle unaligned memory safely.
Files affected:
src/storage/wal/wal_entry_impl.cpp
Expected behavior
No response
Additional information
No response