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

Change logic related to disposed checkerPools #941

Merged
merged 4 commits into from
Aug 19, 2024
Merged
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
6 changes: 4 additions & 2 deletions Source/ExecutionEngine/VerificationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void Cancel() {

StartRun(cancellationSource.Token).ToObservable().
Catch<IVerificationStatus, OperationCanceledException>(_ => Observable.Return(new Stale())).
Catch<IVerificationStatus, ObjectDisposedException>(e => cancellationSource.IsCancellationRequested
? Observable.Return(new Stale()) : Observable.Throw<IVerificationStatus>(e)).
Subscribe(next => {
status.OnNext(next);
}, e => {
Expand All @@ -115,8 +117,8 @@ public void Cancel() {

private async IAsyncEnumerable<IVerificationStatus> StartRun([EnumeratorCancellation] CancellationToken cancellationToken) {
var timeout = Split.Run.Implementation.GetTimeLimit(Split.Options);
var checkerTask = engine.CheckerPool.FindCheckerFor(ProcessedProgram.Program, Split, CancellationToken.None);

var checkerTask = engine.CheckerPool.FindCheckerFor(ProcessedProgram.Program, Split, cancellationToken);
if (!checkerTask.IsCompleted) {
yield return new Queued();
}
Expand Down
10 changes: 6 additions & 4 deletions Source/VCGeneration/CheckerPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public CheckerPool(VCGenOptions options)

public async Task<Checker> FindCheckerFor(Program program, Split? split, CancellationToken cancellationToken)
{
if (disposed) {
throw new Exception("CheckerPool was already disposed");
}

await checkersSemaphore.WaitAsync(cancellationToken);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this task will still not be cancelled if the checkerpool is disposed of. Can you indicate me how it could be otherwise?

Copy link
Collaborator Author

@keyboardDrummer keyboardDrummer Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call await checkersSemaphore.WaitAsync(cancellationToken); throws an ObjectDisposedException if the CheckerPool is or gets disposed.

try {
if (!availableCheckers.TryPop(out var checker)) {
Expand All @@ -43,6 +39,11 @@ public async Task<Checker> FindCheckerFor(Program program, Split? split, Cancell
private int createdCheckers;
private Checker CreateNewChecker()
{
if (disposed)
{
throw new ObjectDisposedException(nameof(CheckerPool));
}

var log = Options.ProverLogFilePath;
var index = Interlocked.Increment(ref createdCheckers) - 1;
if (log != null && !log.Contains("@PROC@") && index > 0) {
Expand All @@ -57,6 +58,7 @@ public void Dispose()
lock(availableCheckers)
{
disposed = true;
checkersSemaphore.Dispose();
while (availableCheckers.TryPop(out var checker)) {
checker.Close();
}
Expand Down
Loading