nunit: StackOverflowException when running tests with nunit3-console.exe

My apologies in advance if this I’m missing any information here. Please let me know what I can provide to help get to the bottom of this. I am trying to use the nunin3-console.exe runner, but am receiving a stack overflow exception immediately. Interestingly, this works fine on my ElCapitan iMac.

> ../packages/NUnit.Console.3.0.0/tools/nunit3-console.exe" "bin/Debug/XQA.XS.Tests.dll" -where="cat == DotNet" -verbose
NUnit Console Runner 3.0.5797
Copyright (C) 2015 Charlie Poole

Runtime Environment
   OS Version: Microsoft Windows NT 10.0.10240.0
  CLR Version: 4.0.30319.42000

Test Files
    bin/Debug/XQA.XS.Tests.dll

Test Filters
    Where: cat == DotNet

Process is terminated due to StackOverflowException.

Errors and Failures

1) Error :
An existing connection was forcibly closed by the remote host

Server stack trace:
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
   at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[] buffer)
   at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadAndMatchPreamble()
   at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)
   at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)

Test Run Summary
    Overall result: Failed
   Tests run: 0, Passed: 0, Errors: 0, Failures: 0, Inconclusive: 0
     Not run: 0, Invalid: 0, Ignored: 0, Explicit: 0, Skipped: 0
  Start time: 2015-11-20 01:05:37Z
    End time: 2015-11-20 01:05:45Z
    Duration: 8.659 seconds

Results (nunit3) saved as TestResult.xml

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 62 (26 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve looked at stack size when I run tests in resharper test runner and with nunit3-console.exe, and in first case it shows 4MB stack, while the second case shows only 1MB of stack available. I believe this is what causes StackOverflowException for me.

My guess is that these difference are due to 32-bit vs 64-bit, as the default on 32-bit is 1MB and the default on 64-bit is 4MB. That being said, usually 1MB is sufficient due to the way .NET allocates memory. @fakefeik Are you doing something with stackalloc or have some deep recursion in the code? (can you provide the test or an example thereof?)

@CharliePoole After reviewing our code, I think we did actually have a StackOverflowException but I’m not certain (like you said earlier, it’s nigh impossible to troubleshoot these things properly).

Everyone: If you’re getting this, odds are you actually have a stack overflow in your code and you should start with that assumption. NUnit blows up because it’s .NET code also and it has no way of dealing with a StackOverflowException any more than any other .NET code could.