Skip to content

Fix race condition in ReleaseOnDetach test#48747

Merged
davmason merged 4 commits into
dotnet:masterfrom
davmason:profiler_fix
Feb 26, 2021
Merged

Fix race condition in ReleaseOnDetach test#48747
davmason merged 4 commits into
dotnet:masterfrom
davmason:profiler_fix

Conversation

@davmason

Copy link
Copy Markdown
Contributor

Fixes #47098

There was a race condition in the ReleaseOnDetachTest. The call from the managed testcase to request a profiler attach to itself will block until the profiler succeeds in attaching, then the profiler requests a detach instantly. The vast majority of the time it takes a bit for the detach to actually happen, but sometimes the detach could happen before the call to SetBoolPtr happens. Then SetBoolPtr would call in to the profiler after detach and potentially AV.

The fix here is to add synchronization by polling for _doneFlag.

@davmason davmason added this to the 6.0.0 milestone Feb 25, 2021
@davmason davmason requested a review from a team February 25, 2021 08:20
@davmason davmason self-assigned this Feb 25, 2021
@ghost

ghost commented Feb 25, 2021

Copy link
Copy Markdown

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #47098

There was a race condition in the ReleaseOnDetachTest. The call from the managed testcase to request a profiler attach to itself will block until the profiler succeeds in attaching, then the profiler requests a detach instantly. The vast majority of the time it takes a bit for the detach to actually happen, but sometimes the detach could happen before the call to SetBoolPtr happens. Then SetBoolPtr would call in to the profiler after detach and potentially AV.

The fix here is to add synchronization by polling for _doneFlag.

Author: davmason
Assignees: davmason
Labels:

area-Diagnostics-coreclr

Milestone: 6.0.0

Comment thread src/tests/profiler/native/releaseondetach/releaseondetach.cpp Outdated
Comment thread src/tests/profiler/unittest/releaseondetach.cs Outdated
@davmason davmason merged commit a3ed2e2 into dotnet:master Feb 26, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failed: profiler/unittest/releaseondetach/releaseondetach.sh

3 participants