Bug 58837 - System tests: random ObjectDisposedException (System.Net.HttpListener)
Summary: System tests: random ObjectDisposedException (System.Net.HttpListener)
Status: RESOLVED DUPLICATE of bug 39780
Alias: None
Product: iOS
Classification: Xamarin
Component: BCL Class Libraries ()
Version: XI 10.14 (d15-4)
Hardware: PC Mac OS
: --- normal
Target Milestone: 15.4
Assignee: Bugzilla
Depends on:
Reported: 2017-08-17 08:49 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-08-21 16:03 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Rolf Bjarne Kvinge [MSFT] 2017-08-17 08:49:15 UTC

* Open tests/tests.sln
* Select System as the default project
* Run on an iOS device
* Tap "Run Everything".

The bug is random, so it might be necessary to run multiple times to reproduce the problem.


* If run in the IDE with the debugger, the debugger will stop in HttpListener.cs:CheckDisposed (see attached screenshot).
* If not run in the IDE (or when continuing in the IDE), the app crashes since the exception occurs on a background thread an is unhandled:

Unhandled Exception:
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.HttpListener'.
  at System.Net.HttpListener.CheckDisposed () [0x00019] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/HttpListener.cs:426 
  at System.Net.HttpListener.BeginGetContext (System.AsyncCallback callback, System.Object state) [0x00000] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/HttpListener.cs:323 
  at System.Net.ListenerAsyncResult.Complete (System.Net.HttpListenerContext context, System.Boolean synch) [0x000d8] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/ListenerAsyncResult.cs:106 
  at System.Net.ListenerAsyncResult.Complete (System.Net.HttpListenerContext context) [0x00000] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/ListenerAsyncResult.cs:89 
  at System.Net.HttpListener.RegisterContext (System.Net.HttpListenerContext context) [0x000a6] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/HttpListener.cs:455 
  at System.Net.HttpConnection.OnReadInternal (System.IAsyncResult ares) [0x0014c] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/HttpConnection.cs:270 
  at System.Net.HttpConnection.OnRead (System.IAsyncResult ares) [0x0000b] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net/HttpConnection.cs:214 
  at System.Net.Sockets.SocketAsyncResult+<>c.<Complete>b__27_0 (System.Object state) [0x00000] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/System/System.Net.Sockets/SocketAsyncResult.cs:157 
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00015] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1279 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:856 
  at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func`1[TResult] callback) [0x00006] in /work/maccore/master/xamarin-macios/src/ObjCRuntime/Runtime.cs:244 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00009] in /work/maccore/master/xamarin-macios/external/mono/mcs/class/referencesource/mscorlib/system/threading/threadpool.cs:1208 

Full application output: https://gist.github.com/rolfbjarne/343c9c5e70b80d900dd117a482bd11d2
Comment 2 Rolf Bjarne Kvinge [MSFT] 2017-08-21 16:03:21 UTC
Yes, it looks like a duplicate.

*** This bug has been marked as a duplicate of bug 39780 ***