From 4d808ece1fd17e44538027ca41c63a61b1042dab Mon Sep 17 00:00:00 2001 From: Aditya Senthilnathan Date: Wed, 12 Oct 2022 13:05:09 +0530 Subject: [PATCH] Revert "Implemented hacky fix for races in CoyoteRuntime.Dispose" This reverts commit 151f437e5e4d7e1bf88bcbb0ebb1a9cb4138dc7d. --- Source/Core/Runtime/CoyoteRuntime.cs | 42 +++++++++++----------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/Source/Core/Runtime/CoyoteRuntime.cs b/Source/Core/Runtime/CoyoteRuntime.cs index 695ede52..c7a47ca8 100644 --- a/Source/Core/Runtime/CoyoteRuntime.cs +++ b/Source/Core/Runtime/CoyoteRuntime.cs @@ -76,11 +76,6 @@ namespace Microsoft.Coyote.Runtime /// internal readonly Guid Id; - /// - /// Object that is used to synchronize access to the runtime. - /// - private readonly object RuntimeLock; - /// /// The configuration used by the runtime. /// @@ -297,7 +292,6 @@ namespace Microsoft.Coyote.Runtime this.Configuration = configuration; this.Scheduler = scheduler; - this.RuntimeLock = new object(); this.SyncObject = new object(); this.OperationIdCounter = 0; this.IsRunning = true; @@ -2412,28 +2406,26 @@ namespace Microsoft.Coyote.Runtime if (disposing) { RuntimeProvider.Deregister(this.Id); - using (SynchronizedSection.Enter(this.RuntimeLock)) + + foreach (var op in this.OperationMap.Values) { - foreach (var op in this.OperationMap.Values) - { - op.Dispose(); - } - - this.ThreadPool.Clear(); - this.OperationMap.Clear(); - this.ControlledThreads.Clear(); - this.ControlledTasks.Clear(); - this.UncontrolledTasks.Clear(); - this.UncontrolledInvocations.Clear(); - - this.DefaultActorExecutionContext.Dispose(); - this.ControlledTaskScheduler.Dispose(); - this.SyncContext.Dispose(); - this.DeadlockMonitor.Dispose(); - this.SpecificationMonitors.Clear(); - this.TaskLivenessMonitors.Clear(); + op.Dispose(); } + this.ThreadPool.Clear(); + this.OperationMap.Clear(); + this.ControlledThreads.Clear(); + this.ControlledTasks.Clear(); + this.UncontrolledTasks.Clear(); + this.UncontrolledInvocations.Clear(); + + this.DefaultActorExecutionContext.Dispose(); + this.ControlledTaskScheduler.Dispose(); + this.SyncContext.Dispose(); + this.DeadlockMonitor.Dispose(); + this.SpecificationMonitors.Clear(); + this.TaskLivenessMonitors.Clear(); + if (this.SchedulingPolicy is SchedulingPolicy.Interleaving) { // Note: this makes it possible to run a Controlled unit test followed by a production