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

Avoid doing unaligned reads/writes via UnsafePointer #146

Merged
merged 1 commit into from
Dec 12, 2015

Conversation

mstorsjo
Copy link
Contributor

Instead read/write individual bytes via UnsafePointer.

This fixes crashes that only happen when optimization is turned on,
on 32 bit arm builds.

Not all processors support unaligned reads/writes of 64 bit values.
Without optimizations, the reads/writes probably end up handling one
byte at a time (like this commit makes it do), while higher
optimization levels convert it to single reads/writes of the full
size, which may require that the pointer is properly aligned.

Instead read/write individual bytes via UnsafePointer<UInt8>.

This fixes crashes that only happen when optimization is turned on,
on 32 bit arm builds.

Not all processors support unaligned reads/writes of 64 bit values.
Without optimizations, the reads/writes probably end up handling one
byte at a time (like this commit makes it do), while higher
optimization levels convert it to single reads/writes of the full
size, which may require that the pointer is properly aligned.
@nuclearace
Copy link
Contributor

Should fix #77

@daltoniam
Copy link
Owner

Awesome, thank you much for fixing this. @nuclearace agreed.

daltoniam added a commit that referenced this pull request Dec 12, 2015
Avoid doing unaligned reads/writes via UnsafePointer
@daltoniam daltoniam merged commit aeae316 into daltoniam:master Dec 12, 2015
@mstorsjo mstorsjo deleted the avoid-unaligned branch December 14, 2015 09:21
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.

3 participants