Skip to content

Fix: Avoid unaligned serial memory accesses - #339

Closed
emecii wants to merge 1 commit into
ashvardanian:mainfrom
emecii:fix/279-alignment-safe-serial
Closed

emecii wants to merge 1 commit into
ashvardanian:mainfrom
emecii:fix/279-alignment-safe-serial

Conversation

@emecii

@emecii emecii commented Sep 7, 2026

Copy link
Copy Markdown

Fix: Avoid unaligned serial memory accesses

Summary

  • replace the serial copy and move paths' unaligned sz_u64_t* dereferences with an alignment-safe eight-byte transfer helper
  • retain load-before-store ordering so overlapping sz_move_serial calls work in both directions
  • exercise misaligned copy plus forward and backward overlapping moves in the existing C++ memory unit test

Fixes #279.

Testing

  • SZ_TESTS_FILTER='test_memory_(unit|all|safety)' SZ_TESTS_MULTIPLIER=0.1 SZ_TESTS_SEED=279 /tmp/stringzilla-279-cpp20-ubsan
  • SZ_TESTS_MULTIPLIER=0.1 SZ_TESTS_SEED=279 /tmp/stringzilla-279-cpp20
  • direct Clang C++11/14/17 compilation of test/string.cpp

@ashvardanian

Copy link
Copy Markdown
Owner

Please check the surrounding lines next to your PR. There is already a built-in setting to avoid misaligned loads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UBSAN reports writing to misaligned address.

2 participants