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

[ObjC] Remove OSReadLittle* due to alignment requirements #6678

Merged
merged 1 commit into from Sep 20, 2019

Conversation

dmaclach
Copy link
Contributor

@dmaclach dmaclach commented Sep 20, 2019

Objective C Protocol buffers can crash on ARM32.

The OSReadLittleInt64 function as defined by Apple reduces down to:

return *(volatile uint64_t *)((uintptr_t)base + byteOffset);

which means we are type-punning using a cast. On ARMv7 and other aligned architectures this can cause crashes.
Minimal example: https://gist.github.com/dmaclach/b10b0a71ae614d304c067cb9bd264336

Language: objective-c
release notes: yes

The OSReadLittleInt64 function as defined by Apple reduces down to:

`return *(volatile uint64_t *)((uintptr_t)base + byteOffset);`

which means we are type-punning using a cast. On ARMv7 and other aligned architectures this can cause crashes. 
Minimal example: https://gist.github.com/dmaclach/b10b0a71ae614d304c067cb9bd264336
@thomasvl thomasvl self-assigned this Sep 20, 2019
@thomasvl thomasvl changed the title Remove OSReadLittle* due to alignment requirements [ObjC] Remove OSReadLittle* due to alignment requirements Sep 20, 2019
@thomasvl thomasvl merged commit 4702ba9 into protocolbuffers:master Sep 20, 2019
thomasvl pushed a commit to thomasvl/protobuf that referenced this pull request Sep 20, 2019
)

The OSReadLittleInt64 function as defined by Apple reduces down to:

`return *(volatile uint64_t *)((uintptr_t)base + byteOffset);`

which means we are type-punning using a cast. On ARMv7 and other aligned architectures this can cause crashes. 
Minimal example: https://gist.github.com/dmaclach/b10b0a71ae614d304c067cb9bd264336

Fixes protocolbuffers#6679
thomasvl pushed a commit to thomasvl/protobuf that referenced this pull request Sep 20, 2019
)

The OSReadLittleInt64 function as defined by Apple reduces down to:

`return *(volatile uint64_t *)((uintptr_t)base + byteOffset);`

which means we are type-punning using a cast. On ARMv7 and other aligned architectures this can cause crashes. 
Minimal example: https://gist.github.com/dmaclach/b10b0a71ae614d304c067cb9bd264336

Fixes protocolbuffers#6679
@dmaclach dmaclach deleted the patch-4 branch January 22, 2020 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants