Skip to content

[CoreFoundation] Fix incorrect cast in _CFRuntimeCreateInstance. #1806

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

Merged
merged 1 commit into from
Dec 17, 2018

Conversation

drodriguez
Copy link
Contributor

_cfinfoa field of CFRuntimeBase is an _Atomic(uint64_t), but for some
reason it was being accessed from a uint32_t pointer (which I think
violates strict aliasing rules). This was working for little endian
architectures, but would have failed for big endian architectures when
writing the value back into the MSB instead of the LSB.

The fix uses the right size (64 bits) and removes the castings where
possible. However, to avoid the _Atomic to be honored, the field is
still casted to an uint64_t, which might hide future errors (like the
situation this is trying to fix).

_cfinfoa field of CFRuntimeBase is an _Atomic(uint64_t), but for some
reason it was being accessed from a uint32_t pointer (which I think
violates strict aliasing rules). This was working for little endian
architectures, but would have failed for big endian architectures when
writing the value back into the MSB instead of the LSB.

The fix uses the right size (64 bits) and removes the castings where
possible. However, to avoid the _Atomic to be honored, the field is
still casted to an uint64_t, which might hide future errors (like the
situation this is trying to fix).
@compnerd
Copy link
Member

@swift-ci please test

@compnerd compnerd merged commit c7d1cd6 into swiftlang:master Dec 17, 2018
@drodriguez drodriguez deleted the fix-be-wrong-cast branch July 16, 2019 22:40
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.

2 participants