Skip to content

[5.4][Runtime] Fix StableAddressConcurrentReadableHashMap threading crash. #35186

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

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Dec 21, 2020

Cherry-pick #35185 to 5.4.

StableAddressConcurrentReadableHashMap::getOrInsert had a race condition in the first lookup, where the snapshot was destroyed before the pointer was extracted from the returned wrapper. Fix this by creating the snapshot outside the if so that it stays alive.

rdar://problem/71932487

StableAddressConcurrentReadableHashMap::getOrInsert had a race condition in the first lookup, where the snapshot was destroyed before the pointer was extracted from the returned wrapper. Fix this by creating the snapshot outside the if so that it stays alive.

rdar://problem/71932487
@mikeash mikeash requested a review from tbkka December 21, 2020 21:54
@mikeash
Copy link
Contributor Author

mikeash commented Dec 21, 2020

@swift-ci please test

@mikeash
Copy link
Contributor Author

mikeash commented Dec 21, 2020

@swift-ci please test windows platform

@jckarter
Copy link
Contributor

Sneaky. I wonder if the snapshot's API could all be turned into & methods, so that they're impossible to accidentally use on a temporary snapshot, e.g.:

struct Butt {
  void foo() &;
};

void butt() {
  Butt().foo(); // an error, because the method requires an lvalue but is given a temporary
}

@mikeash mikeash merged commit c1dd6f9 into swiftlang:release/5.4 Dec 22, 2020
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