Search code examples
.netrecursion64-bitstack-overflow

StackOverflowException thrown on x64 systems; works properly on x86


this is just a "to be sure" question here. Are there any known special limitations/bugs on recursion / loops for the x64 systems in .NET 4?

My case is pretty simple - a program runs fine on any x86 system but it crashes with a StackOverflowException on x64 systems (the program includes some xml/mapping code that contains recursions in several places and such).

Currently the only solution for this problem is to call corflags /32BIT+ on my assembly (and the program starts running correctly). But I was wondering - is there any special cases that are known to cause bugs / issues on x64?

Thanks.


Solution

  • Pointers require more memory to represent in x64 (twice as much, in fact). As such, you'll use a lot more memory, and so deep recursion can cause stack overflows on x64 earlier than it would on x86. You might want to try raising the stack limit to mitigate this problem.