Stack overflow in vs.net c++ program

G

Guest

I am attempting to port a C code that runs OK on a number of Linux and Unix
machines to Windows XP using Visual Studio C++. I have set the program up as
a console application, but when I try to run it I get a stack overflow:

Unhandled exception at 0x0041e715 in NewMD.exe: 0xC00000FD: Stack overflow.

The call stack is:

NewMD.exe!_chkstk() Line 91
NewMD.exe!mainCRTStartup() Line 259 +0x19
kernel32.dll!77e814c()

All this appears to be happening before my C code actually does anything.

Does anyone know what the problem is and how to fix it

Thanks
David
 
D

Daniel =?iso-8859-1?Q?Lidstr=F6m?=

I am attempting to port a C code that runs OK on a number of Linux and Unix
machines to Windows XP using Visual Studio C++. I have set the program up as
a console application, but when I try to run it I get a stack overflow:

Unhandled exception at 0x0041e715 in NewMD.exe: 0xC00000FD: Stack overflow.

The call stack is:

NewMD.exe!_chkstk() Line 91
NewMD.exe!mainCRTStartup() Line 259 +0x19
kernel32.dll!77e814c()

All this appears to be happening before my C code actually does anything.

Does anyone know what the problem is and how to fix it

It could be the allocation of some very large object. For example, a static
class variable that is very large. If the stack space is smaller for your
windows program than your unix program, the variable might not fit. Either
increase stack size or allocate such objects dynamically (i.e. on the
heap).
 
D

David Brewer

There are number of reasons for stack overflow exception. As Daniel pointed,
program (a function??) could be allocating a very large stack space.Or,

- You are copying something to a variable on the stack, and buffer exceeds
bounds of the stack
- You are recursively calling a function and that never ends
- Incorrect function pointer casting

These are all I can think right now.
 

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