Skip to content

fix potential race in PackageCollections.refreshCollections #3232

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
Feb 2, 2021

Conversation

tomerd
Copy link
Contributor

@tomerd tomerd commented Feb 2, 2021

motivation: CI crashes in PackageCollectsTest::testBrokenRefresh suggest a race condition in the code

changes:

  • change ThreadSafeArrayStore::apend to return the current count in a thread safe manner
  • update the callsite to use the count returned from append instead of after the append -- which could be racy

motivation: CI crashes in PackageCollectsTest::testBrokenRefresh suggest a race condition in the code

changes:
* change ThreadSafeArrayStore::apend to return the current count in a thread safe manner
* update the callsite to use the count returned from append instead of after the append -- which could be racy

rdar://73884751
@tomerd
Copy link
Contributor Author

tomerd commented Feb 2, 2021

@swift-ci please smoke test

Copy link
Contributor

@abertelrud abertelrud left a comment

Choose a reason for hiding this comment

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

LGTM

@tomerd tomerd merged commit 3bef7ed into swiftlang:main Feb 2, 2021
yim-lee added a commit to yim-lee/swift-package-manager that referenced this pull request Mar 3, 2021
Motivation:
`testHappyRefresh` crashed in https://ci.swift.org/job/oss-swift-package-centos-8/975

```
Test Suite 'PackageCollectionsTests' started at 2021-03-02 22:01:52.483
Test Case 'PackageCollectionsTests.testHappyRefresh' started at 2021-03-02 22:01:52.483
Exited with signal code 11
```

This is similar to swiftlang#3232

Modifications:
Both `testHappyRefresh` and `testBrokenRefresh` call `listCollections` after `refreshCollections`, and part of the `listCollections` code where we read collection blobs from the database might be racy since we are not using `ThreadSafeArrayStore`.
yim-lee added a commit that referenced this pull request Mar 4, 2021
Motivation:
`testHappyRefresh` crashed in https://ci.swift.org/job/oss-swift-package-centos-8/975

```
Test Suite 'PackageCollectionsTests' started at 2021-03-02 22:01:52.483
Test Case 'PackageCollectionsTests.testHappyRefresh' started at 2021-03-02 22:01:52.483
Exited with signal code 11
```

This is similar to #3232

Modifications:
Both `testHappyRefresh` and `testBrokenRefresh` call `listCollections` after `refreshCollections`, and part of the `listCollections` code where we read collection blobs from the database might be racy since we are not using `ThreadSafeArrayStore`.
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