Bug 11060 - mdtool clean fails with System.ObjectDisposedException
Summary: mdtool clean fails with System.ObjectDisposedException
Status: RESOLVED DUPLICATE of bug 12676
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: 4.0.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Lluis Sanchez
Depends on:
Reported: 2013-03-11 21:10 UTC by Sebastien Pouliot
Modified: 2013-06-20 04:25 UTC (History)
3 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 Sebastien Pouliot 2013-03-11 21:10:48 UTC
Doing a "make clean" of the test suite fails when using Mono 3.0.4. They are iOS projects - so it could be addin related or a more general issue.

The command is:

"$(MDTOOL)" -v build -t:Clean "-c:Debug|iPhoneSimulator"

The cleaning is done then it fails (shutdown?) with:

Unhandled Exception:
System.ObjectDisposedException: The object was used after being disposed.

Server stack trace: 
  at System.Net.Sockets.Socket.Poll (Int32 time_us, SelectMode mode) [0x0009c] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System/System.Net.Sockets/Socket.cs:1499 
  at System.Runtime.Remoting.Channels.Tcp.ReusableTcpClient.get_IsAlive () [0x00008] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:148 
  at System.Runtime.Remoting.Channels.Tcp.TcpConnection.get_IsAlive () [0x00000] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:183 
  at System.Runtime.Remoting.Channels.Tcp.HostConnectionPool.GetConnection () [0x0005a] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:234 
  at System.Runtime.Remoting.Channels.Tcp.TcpConnectionPool.GetConnection (System.String host, Int32 port) [0x0005c] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:105 
  at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage (IMessage msg, ITransportHeaders requestHeaders, System.IO.Stream requestStream, ITransportHeaders& responseHeaders, System.IO.Stream& responseStream) [0x00025] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientTransportSink.cs:183 
  at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (IMessage msg) [0x0006c] in /Users/builder/data/lanes/mono-mac-ui-refresh-master/4dc79257/source/bockbuild/profiles/mono-mac-release/build-root/mono-3.0.4/_build/mono-3.0.4.git/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs:157
Comment 1 Øystein Krog 2013-03-19 04:49:02 UTC
We are also seeing this exception on our build server, but for us it seems to be for "build" as well as clean.
Has anyone found a workaround?
Comment 2 Øystein Krog 2013-03-19 05:43:52 UTC
We managed to get around this by completely removing mono, xamarin studio and monotouch folders etc from the machine, and then reinstalling.
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-05-31 03:55:15 UTC
I can reproduce this fairly consistently locally, and some debugging reveals this:

(gdb) bt
#0  0x98c6406c in _exit ()
#1  0x01193038 in mono_internal_thread_unhandled_exception (exc=0x1805f30) at threadpool.c:1677
#2  0x011b7004 in mono_gc_run_finalize (obj=0x9b46090, data=0x0) at gc.c:221
#3  0x011b7e82 in finalize_domain_objects [inlined] () at :1046
#4  0x011b7e82 in finalizer_thread (unused=0x0) at gc.c:1093
#5  0x0118f266 in start_wrapper_internal [inlined] () at :608
#6  0x0118f266 in start_wrapper (data=0x12e280) at threads.c:653
#7  0x012339aa in thread_start_routine (args=0x8db7b8) at wthreads.c:288
#8  0x012441d1 in inner_start_thread (arg=0x12e1e0) at mono-threads-posix.c:49
#9  0x945e25b7 in _pthread_start ()
#10 0x945ccd4e in thread_start ()

(gdb) up
(gdb) p exc->vtable->klass->name
$1 = 0x636165 "ObjectDisposedException"

(gdb) up
(gdb) p ((MonoObject *) obj)->vtable->klass->name
$2 = 0x17b41f7 "RemoteProjectBuilder"
(gdb) p ((MonoObject *) obj)->vtable->klass->name_space
$3 = 0x17b1203 "MonoDevelop.Projects.Formats.MSBuild"

So MonoDevelop.Projects.Formats.MSBuild.RemoteProjectBuilder's  finalizer is throwing an ObjectDisposedException.

Note that this is happening when the process has started shutting down.

Note to self: this is when building bindings-test project.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2013-05-31 04:05:39 UTC
This patch confirms this is the issue: https://gist.github.com/rolfbjarne/bf77fe11dc654fb0fea9 - the process now exits successfully (it prints "Exception in ~RemoteProjectBuilder:" and the same stack traces as in the initial description).
Comment 5 Lluis Sanchez 2013-06-20 04:25:56 UTC

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