You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WaitHandles: Possible race condition in InternalWaitOneAsync() #120
[Test]publicasyncTaskTestCancellationDoesNotLeadToLostSignal([Values]boolasync){varsemaphore=newWaitHandleDistributedSemaphore(nameof(this.TestCancellationDoesNotLeadToLostSignal),2);awaitusingvar_=awaitsemaphore.AcquireAsync(TimeSpan.FromSeconds(1));for(vari=0;i<50;++i){usingvarbarrier=newBarrier(2);usingvarsource=newCancellationTokenSource();varacquireTask=Task.Run(async()=>{barrier.SignalAndWait();try{if(async){awaitusing var _ =awaitsemaphore.AcquireAsync(cancellationToken:source.Token);}else{usingvar_=semaphore.Acquire(cancellationToken:source.Token);}}catchwhen(source.Token.IsCancellationRequested){}});varcancelTask=Task.Run(()=>{barrier.SignalAndWait();source.Cancel();});awaitTask.WhenAll(acquireTask,cancelTask);}awaitusingvarhandle=awaitsemaphore.TryAcquireAsync();Assert.IsNotNull(handle);// if we lost even a single signal due to cancellation in the loop above, this will fail}
Activity
madelson commentedon Jul 8, 2022
Reproduction:
Resignal waitHandle if we choose to ignore its signal due to cancella…
Further race condition handling for #120