What might cause a stack overflow before a program starts? [FIXED]

Started by
7 comments, last by Rayno 19 years ago
This is a pretty odd error. When I start my program I get a message saying: "The application failed to initialize properly (0xc00000fd). Click on OK to terminate the application." In debug mode it will tell me that there was a stack overflow. But there is no source code for where it is. I'm stumped. Does anyone have any ideas? [Edited by - Rayno on March 28, 2005 5:53:11 PM]
Advertisement
What a waste of time... You didn't give the language, the platform, let alone the source code..
Sorry, language is c++, on win32.

I didn't post source code because I don't know what part of my 10k+ line project to post.
you're staticly allocating more that about 1mb of storage, switch over to dynamic memory allocation for your arrays.
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
Check your statics, sounds like a classic case of a static class gone bad.
++Alex
Quote:Original post by DigitalDelusion
you're staticly allocating more that about 1mb of storage, switch over to dynamic memory allocation for your arrays.


I only use static arrays in a couple places and they are all < 1K.

Quote:achacha
Check your statics, sounds like a classic case of a static class gone bad.


Good idea. I'm looking.


Could it be in any way related to templated classes? Because thats what I was working on before it started doing this.

Thanks for the ideas guys.
well say that you have a class that staticy allocates 512bytes and the you happe to have oh let's say 2k of those... blammo goes all your static memory.

recursive template instantation could also be the answer, but you got a total of about 1mb for global data (on a winxp box diffrent OS's and settings have diffrent amount of stackspace given to processes)
HardDrop - hard link shell extension."Tread softly because you tread on my dreams" - Yeats
This error can also come up if you throw an exception in a static class, since they get initialized first and exception is not caught withing the static code you propagate the exception to the initializer and it will show an error and not continue. You can try looking at the code you just worked on and surround it in a try/catch block with output to console (or debug output, depending on the type of app you have).

With Microsoft (if you are using it), access violation is not a real exception but it's a hardware expection called __exception and the only useful way to catch it is with catch(...) or to use Microsoft hardware exception TRY/CATCH macros.


Here is a sample

#include <iostream>static void somefunction(){  try  {    // You code here (sample of access violation to follow)    char *p = NULL;    *p = 1;  }  catch(std::exception& e)  {    // STDC exception    std::cout << e.what() << std::endl;  }  catch(...)  {    std::cout << "Unknown or hardware exception caught" << std::endl;  }}
++Alex
I'm pretty sure I found it!

I ened up using WinDiff to compare an older (working) version.
Heres essentially what I did:

class Base
{
//...
};

class Foo : public Base
{
//...
//this class initializes a few Bar's
}

class Bar : public Foo
{
//...
//The base class of Foo create a few Bars which all create more Bars onto infinity.
}


It worked before because I had Bar derive from Base.

Thanks for the help guys.

This topic is closed to new replies.

Advertisement