i#2600: fix race between detach and new thread #2602
Merged
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.
Adds a counter uninit_thread_count which is incremented in UNIX just prior
to a new thread being created. Synchall will keep looping while this
counter is positive, ensuring we avoid races with threads created but not
yet initialized during a detach synchall which then use DR resources after
detach, causing crashes.
Leaves the counter at 0 on Windows where we can't distinguish external vs
internal thread creation, but Windows does have the init_apc_go_native flag
which eliminates some races.
Adds a test. To more reliably hit the race (about half the time) I locally
added a 50ms sleep at the top of dynamo_thread_init().
Fixes #2600