-
Notifications
You must be signed in to change notification settings - Fork 802
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
Internal exception surfacing when calling Post
on disposed MailBoxProcessor
#17849
Comments
This happens with timeouts or cancellation enabled, only then a wait handle is used in Mailbox. |
Minimal repro: open System.Threading
let cts = new CancellationTokenSource()
let mb =
MailboxProcessor.Start( (fun inbox ->
async {
let! _ = inbox.Receive()
let! _ = inbox.Receive()
return ()
}),
cancellationToken = cts.Token
)
// ensure pulse gets created
Thread.Sleep 100
mb.Post 1
mb.Dispose()
mb.Post 2 |
I think getting an ObjectDisposedException is the right scenario if the object was disposed. |
I think the exception happens in a code path that was there before that PR.
This may be a breaking change. It seems the current standard behavior most of the time is waiting indefinitely on a disposed wait handle. Only on rare occasions where the wait handle is disposed while it's not awaited this here bug happens. |
* nullify disposed waithandle * add test * rns --------- Co-authored-by: Tomas Grosup <[email protected]>
I can see the above exception occasionally in this test:
fsharp/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/MailboxProcessorType.fs
Line 316 in e6854f5
I assume the expected behavior here is no exception?
I'll try to come up with consistent minimal repro, but the problem seems to be here:
fsharp/src/FSharp.Core/mailbox.fs
Lines 189 to 193 in 69fa88b
ev
is disposed andSet
will fail.The fix seems to be to also assign null to
pulse
when disposing it here:fsharp/src/FSharp.Core/mailbox.fs
Lines 336 to 346 in 69fa88b
The text was updated successfully, but these errors were encountered: