Skip to content

Commit

Permalink
Change logic related to disposed checkerPools (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardDrummer authored Aug 19, 2024
1 parent e7a229e commit 16c53d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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);
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

0 comments on commit 16c53d9

Please sign in to comment.