Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alignment crash in debug mode #339

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

microtherion
Copy link
Contributor

Fixes #

Recently when testing a nightly Swift snapshot in a project of mine, I came across an alignment crash. It turns out that

  1. There is no guarantee that Data or subdata point to memory with any particular alignment.
  2. In this configuration, with T being UInt32, the subdata was in fact inline data, which is always aligned on a 2 byte boundary but misaligned for 4 bytes.
  3. When compiling in debug mode, load checks for proper alignment and aborts in this case.

The solution is to use the loadUnaligned call which makes no alignment assumptions.

Tests performed

All unit tests keep passing.

Further info for the reviewer

Unfortunately, I have no good isolated reproduction case for the crash, nor can I be more specific about the project in question.

Open Issues

@microtherion
Copy link
Contributor Author

I fixed one linter violation I had accidentally added in my code. The two others were in preexisting code; should I fix those as well?

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.

1 participant