Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 57705 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
To send JSON RPC requests to my server, I'm calling WebRequest's GetRequestStreamAsync() once a second. Unfortunately, I get an ObjectDisposedException every hour or two:
> System.ObjectDisposedException: System.ObjectDisposedException: Cannot access a disposed object.
> Object name: 'System.Net.Sockets.NetworkStream'.
> at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00059] in /build/mono-126.96.36.199/mcs/class/System/System.Net/HttpWebRequest.cs:1031
> at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, System.Threading.Tasks.Task`1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in <37f6d41e94d84ceba93f73ad8a999efc>:0
> --- End of stack trace from previous location where exception was thrown ---
> at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <37f6d41e94d84ceba93f73ad8a999efc>:0
> at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <37f6d41e94d84ceba93f73ad8a999efc>:0
> at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <37f6d41e94d84ceba93f73ad8a999efc>:0
> at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <37f6d41e94d84ceba93f73ad8a999efc>:0
> at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <37f6d41e94d84ceba93f73ad8a999efc>:0
> at PLSNetwork.Network+<SendDataViaRpcAsync>d__86`1[T].MoveNext () [0x00334] in <daa2e52e162d40a4b36d02fa848aa03c>:0
Could this be a race condition in Mono? Happens (at least) in 5.0 and 5.2.
If I call GetRequestStreamAsync() more often, it gets worse. Sometimes I get ObjectDisposedExpections every few minutes!
I'm going to check if this bug depends on the WebRequest settings I use (MaxIdleTime, ConnectionLimit, etc.).
Any help is appreciated!
Might be related to Bug 54059 ("Sporadic objectDisposed exception in client http POST request") or https://github.com/mono/mono/pull/4693 ("[WebConnection] Fix race condition between Close and BeginWrite")?
Hello, this is likely a race condition in the HTTP stack. Could you please provide a repro case so we can look at it? Anything, even if it takes a few minutes to reproduce, would be enough. Thank you.
Created attachment 23215 [details]
MWE to reproduce the bug
I attached a MWE. This sets up a simple web server on port 4321 and then continuously sends POST requests to this server.
> mcs Program.cs && mono --debug Program.exe
This should lead to a ObjectDisposedException every few seconds.
The exception does not happen if KeepAlive is true!
I hope this helps and the reason is not a mistake in my code.
I reproduce the bug with the sample you provided, and it's takes a bit longer than a few seconds (a few minutes). I could also reproduce on macOS.
Thank you very much,
Needs to be triaged against the new web stack.