Skip to content

Commit

Permalink
reschedule before AutoResetEvent.Reset (#496)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoli-al authored Mar 5, 2024
1 parent 3a04e9e commit 8abdd30
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Source/Test/Rewriting/Types/Threading/EventWaitHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ internal bool Reset(CoyoteRuntime runtime)
{
runtime.NotifyUncontrolledSynchronizationInvocation("EventWaitHandle.Reset");
}
else if (runtime.Configuration.IsLockAccessRaceCheckingEnabled)
{
runtime.ScheduleNextOperation(current, SchedulingPointType.Interleave);
}

this.IsSignaled = false;
return true;
Expand Down
24 changes: 24 additions & 0 deletions Tests/Tests.BugFinding/Synchronization/AutoResetEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@ public void TestWaitDeadlock()
replay: true);
}

[Fact(Timeout = 5000)]
public void TestResetDeadlock()
{
this.TestWithError(() =>
{
var threadReady = new AutoResetEvent(false);
var autoResetEvent1 = new AutoResetEvent(false);
var task = Task.Run(() =>
{
threadReady.WaitOne();
autoResetEvent1.Set();
});

threadReady.Set();
autoResetEvent1.Reset();
autoResetEvent1.WaitOne();
},
errorChecker: (e) =>
{
Assert.StartsWith("Deadlock detected.", e);
},
configuration: this.GetConfiguration().WithLockAccessRaceCheckingEnabled().WithTestingIterations(20));
}

[Fact(Timeout = 5000)]
public void TestWaitWithAllIndexesSet()
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/compare-rewriting-diff-logs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ $targets = [ordered]@{
$expected_hashes = [ordered]@{
"rewriting" = "4CDA15D6A718DA0290489A50906F1B2364E9B4562F72D48A59284299B783C5BF"
"rewriting-helpers" = "676906904C5AB80B10069113CA70F5D5EA26A0C2BFB8D6B4EAE46E602BF1AEAE"
"testing" = "0112C27DC0C301BA980E598C484CFABA4F881F5E91FDD74107ADE0002A6901A4"
"testing" = "786F4C49E4C7361F9D91BA0DC61E05F33E3E04BB284ACF204BB9DBD73498AFEB"
"actors" = "492A23570BEDA4A9DF0D55DBCD7DB7B5D43A7FA1E9906BFF0CF98E477BBBBF55"
"actors-testing" = "C9E531EC9C367CFA9E44DCC1F9524D2D92F026E0744CC7C65FE016B621E5B659"
}
Expand Down

0 comments on commit 8abdd30

Please sign in to comment.