From f9068a6508414a290efefd198ebba212bbbb2d29 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Wed, 28 Feb 2024 13:00:41 -0500 Subject: [PATCH 1/3] Reschedule before AutoResetEvent.Reset --- Source/Test/Rewriting/Types/Threading/EventWaitHandle.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Test/Rewriting/Types/Threading/EventWaitHandle.cs b/Source/Test/Rewriting/Types/Threading/EventWaitHandle.cs index e1540d754..e7ce06d5a 100644 --- a/Source/Test/Rewriting/Types/Threading/EventWaitHandle.cs +++ b/Source/Test/Rewriting/Types/Threading/EventWaitHandle.cs @@ -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; From 7a39498776fafb3395ec05f04b8e723c4c80dbd5 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Fri, 1 Mar 2024 10:34:25 -0500 Subject: [PATCH 2/3] Add test. --- .../Synchronization/AutoResetEventTests.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Tests/Tests.BugFinding/Synchronization/AutoResetEventTests.cs b/Tests/Tests.BugFinding/Synchronization/AutoResetEventTests.cs index 0b2862c86..cddbfaca8 100644 --- a/Tests/Tests.BugFinding/Synchronization/AutoResetEventTests.cs +++ b/Tests/Tests.BugFinding/Synchronization/AutoResetEventTests.cs @@ -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() { From a82b43a7f6c9f956cce806bf9075ef8847647fc1 Mon Sep 17 00:00:00 2001 From: Ao Li Date: Sat, 2 Mar 2024 09:45:41 -0500 Subject: [PATCH 3/3] Update rewrite diff hash. --- Tests/compare-rewriting-diff-logs.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/compare-rewriting-diff-logs.ps1 b/Tests/compare-rewriting-diff-logs.ps1 index 91a891910..67d931497 100644 --- a/Tests/compare-rewriting-diff-logs.ps1 +++ b/Tests/compare-rewriting-diff-logs.ps1 @@ -15,7 +15,7 @@ $targets = [ordered]@{ $expected_hashes = [ordered]@{ "rewriting" = "4CDA15D6A718DA0290489A50906F1B2364E9B4562F72D48A59284299B783C5BF" "rewriting-helpers" = "676906904C5AB80B10069113CA70F5D5EA26A0C2BFB8D6B4EAE46E602BF1AEAE" - "testing" = "0112C27DC0C301BA980E598C484CFABA4F881F5E91FDD74107ADE0002A6901A4" + "testing" = "786F4C49E4C7361F9D91BA0DC61E05F33E3E04BB284ACF204BB9DBD73498AFEB" "actors" = "492A23570BEDA4A9DF0D55DBCD7DB7B5D43A7FA1E9906BFF0CF98E477BBBBF55" "actors-testing" = "C9E531EC9C367CFA9E44DCC1F9524D2D92F026E0744CC7C65FE016B621E5B659" }