Stack overflow

  • Thread starter Thread starter Mikhail Pilin
  • Start date Start date
M

Mikhail Pilin

I have got .NET application which has been compiled under Visual Studio 2005
Beta 2. It is absolutely correctly wotk under v2.0.50215 framework under
Windows XP for IA32. I have got the stack overflow problem when I try to run
this application under Windows 2003-64 for AMD64. How can run my application
under AMD64?
 
By attaching a debugger and inspecting your call stack, stack overflow is an
indication the you recurse too deeply, that it works on 32 bit windows is no
guarantee that it works on 64 bit OSses, the stack is still a scarse
resource and the number of slots taken per stack frame is larger than on 32
bit windows (the number of caller-saved register is much larger).
Note that i v2.0 you can allocate more stack space for your threads using
the Thread constructor overload with maxStackSize argument.



Willy.
 
Thank you very much for you answer, but could you tell me how much stack
size is for AMD64 platforms by default? How can increase stack size in .NET
applications if I do not have sources for them?
 
Not sure how much it is in v2.0, but I guess "stack reserve" is still 1MB
per thread.
The stack size can be specified for threads created in your application by
using the Thread constructor overload that takes a second maxStackSize
argument. The main thread stack size can be changed using the (Win64) PSDK's
tool Editbin.exe (see /STACK option).

Willy.
 
I write following simple test to catch StackOverflowException in C#
application. As a result it is work under v1.1.4322, but do not work at all
under framework v2.0.50215 for both IA32 and AMD64 platforms.

using System;
namespace StackOverflowTest
{
internal class Program
{
private static void Recurse()
{
Recurse();
}
internal static void Main(string[] args)
{
try
{
Recurse();
}
catch (StackOverflowException)
{
Console.WriteLine("StackOverflowException has been
catched");
}
}
}
}
 
Works for me using 2.0.50727.
Note that the CLR doesn't guarantee that StackOverflowException can be
catched, if your stack guard page is overwritten, there is simply no space
left to handle the exception.

Wily.

PS. I would strongly suggest you post Beta2 issues to the forums for Whidbey
at http://forums.microsoft.com
This NG is for released versions of the framework.
 
Back
Top