Stack overflow

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?
 
W

Willy Denoyette [MVP]

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.
 
M

Mikhail Pilin

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?
 
W

Willy Denoyette [MVP]

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.
 
M

Mikhail Pilin

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");
}
}
}
}
 
W

Willy Denoyette [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top