nunit-console: Runtime.Remoting.RemotingException in NUnit.Engine.Runners.ProcessRunner.Dispose
Hi,
I’m trying to migrate my windows build server to linux and now have crashes in my unit tests:
khadmin@khbuild:~/myagent/_work/2/s$ mono ./thirdparty/tools/NUnit/nunit3-console.exe --labels=All --noheader ./buildartifacts/KH.Tests.dll /result=./buildartifacts/EventsCursorTestsResults.xml
Runtime Environment
OS Version: Linux 4.4.0.62
CLR Version: 4.0.30319.42000
Test Files
./buildartifacts/KH.Tests.dll
=> KH..Tests.when_something.test_xx
System.Runtime.Remoting.RemotingException: Tcp transport error. ---> System.Runtime.Remoting.RemotingException: Connection closed
at System.Runtime.Remoting.Channels.Tcp.TcpMessageIO.StreamRead (System.IO.Stream networkStream, System.Byte[] buffer, System.Int32 count) [0x00014] in <d849815271d74866b18b5a29e4184d0c>:0
at System.Runtime.Remoting.Channels.Tcp.TcpMessageIO.ReceiveMessageStatus (System.IO.Stream networkStream, System.Byte[] buffer) [0x00000] in <d849815271d74866b18b5a29e4184d0c>:0
--- End of inner exception stack trace ---
Server stack trace:
at System.Runtime.Remoting.Channels.Tcp.TcpMessageIO.ReceiveMessageStatus (System.IO.Stream networkStream, System.Byte[] buffer) [0x0001a] in <d849815271d74866b18b5a29e4184d0c>:0
at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg, System.Runtime.Remoting.Channels.ITransportHeaders requestHeaders, System.IO.Stream requestStream, System.Runtime.Remoting.Channels.ITransportHeaders& responseHeaders, System.IO.Stream& responseStream) [0x00061] in <d849815271d74866b18b5a29e4184d0c>:0
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage (System.Runtime.Remoting.Messaging.IMessage msg) [0x0006c] in <d849815271d74866b18b5a29e4184d0c>:0
Exception rethrown at [0]:
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) NUnit.Engine.Agents.RemoteTestAgent:Stop ()
at NUnit.Engine.Runners.ProcessRunner.Dispose (System.Boolean disposing) [0x0004b] in <7b0953727751470ab10f0e0b547b85ae>:0
May be this is known issue?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (6 by maintainers)
Commits related to this issue
- workaround nunit console error on mono, with multiple test assemblies error: The object with ID 2 implements the IObjectReference interface for which all dependencies cannot be resolved. The likely c... — committed to enricosada/Paket by enricosada 6 years ago
- workaround nunit console error on mono, with multiple test assemblies error: The object with ID 2 implements the IObjectReference interface for which all dependencies cannot be resolved. The likely c... — committed to enricosada/Paket by enricosada 6 years ago
- workaround nunit console error on mono, with multiple test assemblies error: The object with ID 2 implements the IObjectReference interface for which all dependencies cannot be resolved. The likely c... — committed to enricosada/Paket by enricosada 6 years ago
I’ve spent some time and now have more information about cause of this issue.
There is a race between
ProcessRunner.Dispose(bool)which calls at some point something like:And
nunit-agents/Program.cswith code like:So, my guess is that problem is that remote runner process receives stop signal and immiditely closes tcp connection while Host process tries gracefully finalize tcp connection which is already closed at that moment.
Just to work around, I can either ignore that exception in
ProcessRunner.Dispose()or put pause innunit-agent/Program.csand both should help.Sure, I could be wrong with all that, but quick investigation ended up with such conclusion.
In general, I send people to an appropriate dev build on MyGet. Those are already reviewed and merged, whereas appveyor builds may or may not be. The MyGet builds are like our continuous beta release toward the next version.
@jnm2 I don’t think my changes will help for @craigfowler. You cannot install on Linux, so it won’t find another engine and my repro happens all the time.
I am still seeing this in NUnit.ConsoleRunner v3.7.0 (from NuGet) using Linux/Mono. It’s intermittent and doesn’t crash every time.
I have a log of the whole build used to reproduce this available on Travis. In that log, the crash above is recorded starting on line 2784. I think that the rest of the log should contain just about everything else about the build environment you might possibly want to know.
@jnm2 I can confirm that putting delay fixes (works around) this particular problem. That was what I actually did for my build server. Thanks for better fix!
This looks to be very much related to issue https://github.com/nunit/nunit/issues/1834 where we get a similar stack trace about a closed connection when disposing. Obviously this is slightly different since you’re running mono and not using the explore flag, but I’d hazard a guess that they’re the same underlying bug.