Archived

This topic is now archived and is closed to further replies.

dragon376

ESP error ... HELP!!!!!!!!!!!!!!!!!!

Recommended Posts

dragon376    140
The program is a OpenGL 3D game, that is many function call per window loop. The error only occurs when compiled in debug version which make me think of a compiler setting problem. The program either crashes telling me that the variable "done" in the main window loop doesn''t exist or there is the following error message: " Debug Error! Program: ... path ...\Program.exe Module: File: i386\chkesp.c Line: 42 The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention " I tried both calling convention "_cdecl" and "_stdcall" both fails.

Share this post


Link to post
Share on other sites
dragon376    140
MORE INFO
After some testing, I could pin point the problem.
in VC++, Project Setting, C/C++ tab, Debug: scroll down menu
If I change from "Program Database for Edit and Continue" to "none", the program doesn''t crash anymore.

Now I would like to understand this error better. I suppose that this option let me modify the program and recompile on the fly. But what does it do behind the scene.

THANKS.

Share this post


Link to post
Share on other sites
Shannon Barber    1681
You turned off the debug code - you didn''t fix the problem!

If ESP gets whacked like that if usually mean you called a function using the wrong calling convetion. Like you called a __stdcall function as though it were a __cdecl, etc...

Do you dynamically load any dlls or use function or method pointers anywhere? Perhaps even a Win32 or OGL callback function is not properly defined/declared.

Share this post


Link to post
Share on other sites
dragon376    140
Actually, I found that if I choose the "Program Database" without "for Edit and Continue", it works. So for some reason, the information added to "edit and continue" screws up my code. BUT, the only place where I precise the calling convention is in the settings, I don''t put the calling convention in front of each function. It seems that some function such as "new" are using _cdecl though I want to use everywhere _stdcall because it is recommended by Microsoft in MSDN. (Win2000 and XP can have problems with _cdecl according to Microsoft)

I don''t load any dlls, but I have pointers all over the place.
I also have one Win32 callback function.

What would be a proper way to define/declare a callback function?
Where and how can you tell your compiler the calling convention?

Thanks

Share this post


Link to post
Share on other sites