Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Debug covering tests not catching StackOverflowException
johnmwright
#1 Posted : Friday, July 13, 2012 2:12:20 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/27/2011(UTC)
Posts: 45
Location: Chicago, IL

Thanks: 3 times
Was thanked: 7 time(s) in 6 post(s)
If a unit tests ends up generating a StackOverflowException, and I run that test using the "Debug covering test in new task runner process" NCrunch context menu option, when the exception occurs, the debug process just ends. It would be preferred if the debugger paused at the instance of the exception, or otherwise provided some meaningful feedback regarding the exception.

For reference, the NCrunch Tests window shows this text for the tests generating StackOverflows:
NCrunch was unable to retrieve a meaningful result from this test due to an unexpected error - was the execution process terminated?
Remco
#2 Posted : Saturday, July 14, 2012 9:57:46 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
I'm not sure how much can be done to change this behaviour (the CLR is very strict in how it handles stack overflows, and there are limited points of interception). Do you experience the same behaviour if you set the 'Use hosted task runner' global NCrunch configuration setting to 'False'?
johnmwright
#3 Posted : Saturday, July 14, 2012 12:43:36 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/27/2011(UTC)
Posts: 45
Location: Chicago, IL

Thanks: 3 times
Was thanked: 7 time(s) in 6 post(s)
To reproduce, I'm using the following NUnit test fixture:

[TestFixture]
public class Temp
{
[Test]
public void StackOverflowTest()
{
StackOverflowTest();
}
}

Note: you'll have to run it once with the self-referencing call commented out for NCrunch to show the context menus.

When running 'debug covering test in new runner' with 'use hosted task runner' set to True, I get almost no feedback, with control returning back to Visual Studio in edit mode.
With 'use hosted task runner' set to False, the VS debugger does pause when the exception occurs, but is unable to determine the stack location, as seen in this screenshot:
http://imgur.com/rwAbB

For comparision, what I would love to see is that the full stack and source code location of the exception is available in the VS debugger. This is the behavior seen when I use ReSharper's unit test runner in debug mode for the same test, as seen in this screenshot:
http://imgur.com/IGetd

Of course, I have no insight as to how ReSharper does this, or even how you do it, so have absolutely no idea on how to achieve this. :-)
One short-term nice-to-have would be to have the ncrunch test failure message note that a stackoverflow occurred, as this this would help narrow down where to start troubleshooting.


Note: I'm using VS2012 Beta, NCrunch 1.40.0.23b, Resharper 7 Beta, Nunit 2.5.10
1 user thanked johnmwright for this useful post.
Remco on 7/16/2012(UTC)
Remco
#4 Posted : Monday, July 16, 2012 1:06:58 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
NCrunch 1.40b did introduce a certain level of handling for stack overflows, though this doesn't seem to be working reliably and at this stage I have no information on how to properly improve it.

I'll need to keep this issue on the backlog until I can find a smarter way of handling it that will work reliably. Thanks for the detailed information, hopefully in future it will be handled in a cleaner way.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.036 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download