fails before it starts

Aug 24, 2013 at 3:51pm
Hey guys

my program just took a turn for the worst, it starts handing out unhandled exception before it starts executing, before main.

It shows chkstk function where the error is, so i am thinking stack is full but don't know how to fix it, i tried changing stack size and reserve to 10000 but always fails.

after clicking break, there is an arrow next to this line in chkstk function

test dword ptr [eax],eax ; probe page.

thanks

the code is too big to post here.



Aug 24, 2013 at 4:41pm
> it starts handing out unhandled exception before it starts executing, before main.

Dynamic initialization of objects with a static storage duration, at namespace scope, takes place before the first statement in main() is executed.

In your program, the initialization of such an object seems to be causing the unhandled exception.
Aug 24, 2013 at 4:54pm
so i should comment out the global variables and one by one uncomment them to see which one is causing the errr,

i have used static variable as well as a const doube variable.
these are global so can be used by other functions.

i should check those?

thanks
Aug 24, 2013 at 5:06pm
You need to check those variables which have dynamic initialization.

For instance, if you have, in the global namespace

1
2
3
4
5
6
7
8
9
10
const double PI = 3.141592653589793 ; // need not be checked.
const double X = foo() ; // check function foo()
A a ; // check constructor A::A()
extern B b ;
int n = b.value() ; // check that b is initialized, and check the function B::value()
struct C
{
    // ...
    static std::map<std::string,int> m ; // check initializer of C::m
};

Last edited on Aug 24, 2013 at 5:10pm
Aug 25, 2013 at 1:24pm
This is what i have in my global domain of my program.

1
2
3
4
5
6
7
8
9
bool finish=false;

float _angle = -70.0f;
vector<Point3f> vertexpoints;
const float camlen=480.0;
const float camwidth=640.0;
bool finalrender;

static int win;


I don't know what the problem is, i checked them all and i still get error.

i even reduced it to only first 3 and the 6th one and the rest got rid of them.
but still error.

i placed a breakpoint at the first include command line and still crashes before that.

Last edited on Aug 25, 2013 at 1:26pm
Aug 25, 2013 at 2:18pm
> This is what i have

None of those would cause a crash.

Are you using any third party library (ie. any library other than the standard C++ library)?
If so, do any of these define objects with a static storage duration at namespace scope?

Are there shared libraries ( .dll / .so ) involved?
If so, do any of them define initialization routines ( DllMain() / __attribute__((constructor)) or _init() )?

Did you enable all warnings? Were any warnings issued by the compiler or linker?
Aug 26, 2013 at 8:00pm
I am using Opencv, i think they do define objects at namespace as i have a line as using namespace cv;

i am also using opengl
that has a void initrendering function.

but not those ones specificially.

i think i enabled all warnings as i get a whole list of warnings.
i think the warning was issued by the compiler as it shows the warning in the build error list.

Aug 27, 2013 at 6:18am
> i get a whole list of warnings

It might help if you pay attention to those warnings.
Others may be able to offer some assistance if you posted the text of those warnings.
Topic archived. No new replies allowed.