-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix race condition in iterator debug machinery #2060
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
Stephan T. Lavavej (StephanTLavavej)
merged 17 commits into
microsoft:main
from
miscco:fix_debug_iterator_race
Jul 30, 2021
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
df30d2a
Fix race condition in iterator debug machinery
miscco 3aefa0b
Also fix `_Orphan_all`
miscco b0e7238
Address review comments
miscco b97c1be
Only clear the container not destroy it
miscco 8450246
Address more review comments
miscco fee417f
Fix spelling
miscco 6d2c96d
Apply suggestions from code review
miscco 1898dbc
Merge branch 'main' into fix_debug_iterator_race
miscco bd4f30e
`#ifdef __cpp_lib_constexpr_dynamic_alloc` => `#if _HAS_CXX20`
StephanTLavavej 4c62e93
Use `native_matrix.lst` for `<future>`.
StephanTLavavej 6ad37cd
Add banner.
StephanTLavavej 6e6fb72
Naming nitpick: `container` => `Container`
StephanTLavavej a0869d1
Simplify IDL != 2 assignment; containers and proxies point to each ot…
StephanTLavavej eb25249
Avoid unnecessary test of `_Right._Myproxy->_Mycont`.
StephanTLavavej 4199209
Replace `_Orphan_me_v2()` with `_Adopt(nullptr)`.
StephanTLavavej 27fbe4a
Rename to `_v3` for ABI.
StephanTLavavej 307b1d9
Merge branch 'main' into fix_debug_iterator_race
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| RUNALL_INCLUDE ..\native_matrix.lst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| #include <future> | ||
| #include <list> | ||
| #include <set> | ||
| #include <vector> | ||
|
|
||
| using namespace std; | ||
|
|
||
| // Concurrently destroy and invalidate iterators | ||
| template <class Container> | ||
| void test_concurrent_destruction() { | ||
| Container c; | ||
| c.insert(c.begin(), 0); | ||
|
|
||
| vector<typename Container::iterator> iters(1000, c.begin()); | ||
| { | ||
| auto destroyIters = async(launch::async, [&]() { iters.clear(); }); | ||
|
|
||
| auto invalidateIters = async(launch::async, [&]() { c.clear(); }); | ||
| } | ||
| } | ||
|
|
||
| // Concurrently create and invalidate iterators | ||
| template <class Container> | ||
| void test_concurrent_creation() { | ||
| Container c; | ||
| c.insert(c.begin(), 0); | ||
|
|
||
| vector<typename Container::iterator> iters; | ||
| iters.reserve(1000); | ||
|
|
||
| const auto iter = c.begin(); | ||
| { | ||
| auto copyIters = async(launch::async, [&]() { | ||
| for (int i = 0; i < 1000; ++i) { | ||
| iters.push_back(iter); | ||
| }; | ||
| }); | ||
|
|
||
| auto invalidateIters = async(launch::async, [&]() { c.clear(); }); | ||
| } | ||
| } | ||
|
|
||
| int main() { | ||
| test_concurrent_destruction<list<int>>(); | ||
| test_concurrent_destruction<set<int>>(); | ||
| test_concurrent_destruction<vector<int>>(); | ||
|
|
||
| test_concurrent_creation<list<int>>(); | ||
| test_concurrent_creation<set<int>>(); | ||
| test_concurrent_creation<vector<int>>(); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.