Skip to content

[Foundation] Address exclusivity violation in Data #15823

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
Apr 10, 2018

Conversation

devincoughlin
Copy link
Contributor

Address an exclusivity violation in Data's Iterator.next() by changing two private
'let' stored properties to be 'var'.

Making the properties 'var' changes code generation of next() so that the stored
properties are read independently of the other contents of the struct. This prevents
an exclusivity violation when reading '_endIndex' and '_data' while simultaneously
mutating '_buffer' with the call to withUnsafeMutablePointer().

The 'let' pattern is an idiom we would eventually like to support, but for now we
need to remove the exclusivity violation.

@devincoughlin
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor

Can you leave behind a comment about this? Normally the only reason to make properties in a struct use let is because there are invariants across multiple properties, and I think that is in fact the case here.

@gottesmm
Copy link
Contributor

gottesmm commented Apr 9, 2018

Also, probably needs some sort of in text reference to the bug to undo this.

Address an exclusivity violation in Data's Iterator.next() by changing two private
'let' stored properties to be 'var'.

Making the properties 'var' changes code generation of next() so that the stored
properties are read independently of the other contents of the struct. This
prevents an exclusivity violation when reading '_endIdx' and '_data' while
simultaneously mutating '_buffer' with the call to withUnsafeMutablePointer().

The 'let' pattern is an idiom we would eventually like to support (see SR-7396),
but for now we need to remove the exclusivity violation.
@devincoughlin devincoughlin force-pushed the data-exclusivity-warning branch from 07b0b2f to 302d827 Compare April 9, 2018 23:21
@devincoughlin
Copy link
Contributor Author

I've added a comment to the code and included a reference to https://bugs.swift.org/browse/SR-7396 in the commit message.

@devincoughlin
Copy link
Contributor Author

@swift-ci please smoke test and merge

1 similar comment
@devincoughlin
Copy link
Contributor Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit a38fe37 into swiftlang:master Apr 10, 2018
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.

5 participants