Bug 12676 - ObjectDisposedException in ReusableTcpClient.IsAlive getter
Summary: ObjectDisposedException in ReusableTcpClient.IsAlive getter
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- major
Target Milestone: ---
Assignee: Lluis Sanchez
URL:
: 11060 ()
Depends on:
Blocks:
 
Reported: 2013-06-13 12:35 UTC by Bojan Rajkovic [MSFT]
Modified: 2013-07-24 18:11 UTC (History)
6 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Bojan Rajkovic [MSFT] 2013-06-13 12:35:58 UTC
About 3 times out of every 4 running mdtool on Mono 3.0.x, I get the following 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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System/System.Net.Sockets/Socket.cs:1493 
  at System.Runtime.Remoting.Channels.Tcp.ReusableTcpClient.get_IsAlive () [0x00008] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:148 
  at System.Runtime.Remoting.Channels.Tcp.TcpConnection.get_IsAlive () [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:183 
  at System.Runtime.Remoting.Channels.Tcp.HostConnectionPool.GetConnection () [0x0005a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientTransportSink.cs:183 
  at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (IMessage msg) [0x0006c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs:157 

Exception rethrown at [0]: 

  at System.Net.Sockets.Socket.Poll (Int32 time_us, SelectMode mode) [0x0009c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System/System.Net.Sockets/Socket.cs:1493 
  at System.Runtime.Remoting.Channels.Tcp.ReusableTcpClient.get_IsAlive () [0x00008] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:148 
  at System.Runtime.Remoting.Channels.Tcp.TcpConnection.get_IsAlive () [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:183 
  at System.Runtime.Remoting.Channels.Tcp.HostConnectionPool.GetConnection () [0x0005a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientTransportSink.cs:183 
  at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (IMessage msg) [0x0006c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin/build-root/mono-3.0.12/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs:157
Comment 1 Rodrigo Kumpera 2013-06-13 13:04:00 UTC
A little bit of debugging shows that what causes the above exception is a finalizer been invoked by the finalizer thread.

This is the hidden part of the backtrace:

$6 = 0x599cb0 " (wrapper managed-to-native) object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr) + 0x30 (0x86295d8 0x8629642) [0x476e00 - mdtool.exe]"
$5 = 0x5ef310 " (wrapper remoting-invoke) MonoDevelop.Projects.Formats.MSBuild.BuildEngine:UnloadProject (MonoDevelop.Projects.Formats.MSBuild.IProjectBuilder) + 0x94 (0x8628ab0 0x8628b7a) [0x476e00 - mdtool.exe]"
$4 = 0x636fb0 " MonoDevelop.Projects.Formats.MSBuild.RemoteBuildEngine:UnloadProject (MonoDevelop.Projects.Formats.MSBuild.IProjectBuilder) + 0x1d (0x86a0ea0 0x86a0ec2) [0x476e00 - mdtool.exe]"
$3 = 0x63a990 " MonoDevelop.Projects.Formats.MSBuild.RemoteProjectBuilder:Dispose () + 0x30 (0x86a0e20 0x86a0e83) [0x476e00 - mdtool.exe]"
$2 = 0x20566b0 " MonoDevelop.Projects.Formats.MSBuild.RemoteProjectBuilder:Finalize () + 0x14 (0x86a0de8 0x86a0e1b) [0x476e00 - mdtool.exe]"
$1 = 0x2056450 " (wrapper runtime-invoke) object:runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) + 0x41 (0x3fbb180 0x3fbb206) [0x476e00 - mdtool.exe]"


Doing tcp/ip remoting from a finalizer is not reliable and should be avoived.
Comment 2 Bojan Rajkovic [MSFT] 2013-06-13 14:31:47 UTC
Since Kumpera can reproduce, marking as confirmed.
Comment 3 Bojan Rajkovic [MSFT] 2013-06-14 18:51:12 UTC
This was fixed in MonoDevelop.
Comment 4 Lluis Sanchez 2013-06-20 04:25:56 UTC
*** Bug 11060 has been marked as a duplicate of this bug. ***
Comment 5 Bojan Rajkovic [MSFT] 2013-07-24 18:07:03 UTC
It's baaaaaaaaack.

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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System/System.Net.Sockets/Socket.cs:1493 
  at System.Runtime.Remoting.Channels.Tcp.ReusableTcpClient.get_IsAlive () [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:148 
  at System.Runtime.Remoting.Channels.Tcp.TcpConnection.get_IsAlive () [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:183 
  at System.Runtime.Remoting.Channels.Tcp.HostConnectionPool.GetConnection () [0x0005a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientTransportSink.cs:183 
  at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (IMessage msg) [0x0006c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs:157 

Exception rethrown at [0]: 

  at System.Net.Sockets.Socket.Poll (Int32 time_us, SelectMode mode) [0x0009c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System/System.Net.Sockets/Socket.cs:1493 
  at System.Runtime.Remoting.Channels.Tcp.ReusableTcpClient.get_IsAlive () [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:148 
  at System.Runtime.Remoting.Channels.Tcp.TcpConnection.get_IsAlive () [0x00000] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpConnectionPool.cs:183 
  at System.Runtime.Remoting.Channels.Tcp.HostConnectionPool.GetConnection () [0x0005a] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/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 /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientTransportSink.cs:183 
  at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (IMessage msg) [0x0006c] in /private/tmp/source/bockbuild-xamarin/profiles/mono-mac-xamarin-no-pcl/build-root/mono-3.1.2/mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs:157
Comment 6 Alan McGovern 2013-07-24 18:11:34 UTC
The fix is not yet in a stable release, use any build from the 4.1.x series to get the fix.