Skip to content

Conversation

@DougGregor
Copy link
Member

Improve data-race detection for local variables and global/static variables

  • Only diagnose these cases at all, not (e.g.) class instance members
  • For local functions, they run concurrently if they were referenced somewhere
    that runs concurrently

The latter required moving checking of both actor isolation and effects
for local functions to the point at which their enclosing (non-local)
functions are checked, because we need to reason about the
type-checked bodies of local functions.

Improve data-race detection for local variables and global/static variables
* Only diagnose these cases at all, not (e.g.) class instance members
* For local functions, they run concurrently if they were referenced somewhere
  that runs concurrently

The latter required moving checking of both actor isolation and effects
for local functions to the point at which their enclosing (non-local)
functions are checked, because we need to reason about the
type-checked bodies of local functions.

func submitNext() async throws {
await group.add {
await group.add { [submitted,i] in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice that this is caught now!

Nitpitck:

Suggested change
await group.add { [submitted,i] in
await group.add { [submitted, i] in

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, will clean up locally.

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice :-)

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test Linux

@DougGregor DougGregor merged commit dbcf7fe into swiftlang:main Dec 23, 2020
@DougGregor DougGregor deleted the concurrency-better-data-race-checking branch December 23, 2020 07:32
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