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

[SR-8126] Access exclusivity not enforced in Xcode playground #50658

Closed
AnthonyLatsis opened this issue Jun 27, 2018 · 5 comments
Closed

[SR-8126] Access exclusivity not enforced in Xcode playground #50658

AnthonyLatsis opened this issue Jun 27, 2018 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@AnthonyLatsis
Copy link
Collaborator

Previous ID SR-8126
Radar rdar://problem/33820622
Original Reporter @AnthonyLatsis
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Version 10.0 beta (10L176w)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee Hanzlik (JIRA)
Priority Medium

md5: 27914d317978b2419080e4cf9a364d33

Issue Description:

Does not produce any error at all, be it compile- or run-time.

var stepSize = 1
func increment(_ x: inout Int) {
  x += stepSize
  x += stepSize
}
increment(&stepSize)
print(stepSize)
@atrick
Copy link
Member

atrick commented Jun 28, 2018

@swift-ci create

@atrick
Copy link
Member

atrick commented Jun 28, 2018

Thank you for this bug. The problem is that "dynamic" enforcement is not yet supported in playgrounds.

In the example above, although it's obvious to the author, the exclusivity violation isn't obvious to the compiler. `stepSize` looks like a global and `increment` is separately compiled without knowing that stepSize is also the argument. If the whole example were wrapped in another function, we would still have the same problem because `stepSize` would be captured by a closure context before that context is passed to `increment`.

At any rate, swift currently only diagnoses this violation at runtime, which means Playgrounds doesn't catch it.

@atrick
Copy link
Member

atrick commented Apr 16, 2019

This was fixed in Xcode 10.2. Could someone who's watching this bug verify that it works as expected.

@AnthonyLatsis
Copy link
Collaborator Author

Runtime error confirmed:

Simultaneous accesses to 0x119540030, but modification requires exclusive access.
Previous access (a modification) started at  (0x119541333).

@atrick
Copy link
Member

atrick commented Apr 21, 2019

Thanks for double checking the fix.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants