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

Notification

Icon
Error

NCruch crashes (instead of failing) when test code contains stack overflows
realmforge_studios
#1 Posted : Tuesday, April 23, 2013 9:14:02 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/23/2013(UTC)
Posts: 6
Location: Germany

- Install NCrunch 1.45.0.12
- Open VS2012, new Project, C# Class Library
- NuGet - install NUnit
- open the pre-generated Class1.cs and replace it with the following code:

using NUnit.Framework;
namespace Test
{
[TestFixture]
public class Class1
{
[Test]
public void Test()
{
Test();
}
}
}

- Enable NCrunch and let it run the test
-> NCrunch will crash instead of failing because of the stack recursion.

This is especially annoying as the windows crash dialog will keep popping up all the time until you either set the test to ignore or shut down NCrunch completely.

I know it is tricky to handle stack overflow exceptions in C#, but is there some kind of workaround? Its really annoying. Google searches mentioned that you actually can catch an C# StackOverflowException if the CLR is run as "hosted environment".
Remco
#2 Posted : Tuesday, April 23, 2013 10:10:27 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)
Hi, thanks for posting!

Yes - this is a current limitation within the NCrunch environment. NCrunch does not handle stack overflows.

One of the motives behind moving to use hosted task environments with NCrunch was specifically to handle this issue. Unfortunately, the approach doesn't seem to be stable and/or work in all cases. There are plans in place for a different, more reliable approach, although it will require some beta testing before it can be cleared for production use, which means that it needs to be pushed out with a major release (likely V2).

The lack of stack overflow handling is particularly annoying. Until a proper solution can be implemented, the best I can suggest is setting the engine to manual mode until the offending code can be corrected. In most systems, stack overflows are rare enough that they don't cause serious problems during testing ... assuming frustration levels aren't taken into account.

Cheers,

Remco
realmforge_studios
#3 Posted : Tuesday, April 23, 2013 11:32:48 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/23/2013(UTC)
Posts: 6
Location: Germany

Thank you for the reply. In the meantime, I found this site to reduce the UI gutter of the repeadetly failing tests.

Its a howto to turn off the crash popup UI. Unfortunately, its system wide, and I need the popup most of the time for easier post-mortem debugging (mainly for C++ applications). But its instant, so I have two .reg links on my desktop to switch it on/off, which hopefully will ease the stack overflow pain for now. ;)
Remco
#4 Posted : Tuesday, April 23, 2013 9:18:56 PM(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)
Brilliant! Thanks for sharing that link, I think that many people will find it helpful. I will also continue with trying to implement a proper solution.

Cheers,

Remco
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.035 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download