Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset SynchronizedBlock cache after each iteration #510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Source/Test/Rewriting/Types/Threading/Monitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,13 @@ private SynchronizedBlock(CoyoteRuntime runtime, object syncObject)
this.DebugName = $"lock({this.ResourceId})";
}

/// <summary>
/// Called to clear out the cache of synchronized blocks in cases where an iteration
/// may have been aborted and the cache is no longer valid, and may even hold old
/// values that would otherwise not get cleaned up and could impact future iterations.
/// </summary>
internal static void ResetCache () => Cache.Clear();

/// <summary>
/// Creates a new <see cref="SynchronizedBlock"/> for synchronizing access
/// to the specified object and enters the lock.
Expand Down
5 changes: 5 additions & 0 deletions Source/Test/SystematicTesting/TestingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using Microsoft.Coyote.Telemetry;
using Microsoft.Coyote.Visualization;

using SynchronizedBlock = Microsoft.Coyote.Rewriting.Types.Threading.Monitor.SynchronizedBlock;

namespace Microsoft.Coyote.SystematicTesting
{
/// <summary>
Expand Down Expand Up @@ -201,6 +203,9 @@ private TestingEngine(Configuration configuration, TestMethodInfo testMethodInfo

// Create a client for gathering and sending optional telemetry data.
TelemetryClient = TelemetryClient.GetOrCreate(this.Configuration, this.LogWriter);

// Register to clean up the Monitor SynchronizedBlock cache.
this.RegisterEndIterationCallBack(_ => SynchronizedBlock.ResetCache());
}

/// <summary>
Expand Down