Sign in to follow this  
Rayno

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

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What a waste of time... You didn't give the language, the platform, let alone the source code..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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;
}
}


Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this