"Run-Time Check Failure #0 - 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."
Unable to understand what is causing this. Have given a snippet of the code that I think is relevant. Hope you can help me
That code doesn't help. The reason is that we have no idea what the value of those pointers are, whether they're valid, or pointing to valid data.
Your problem is either due to you calling an external function, and you didn't declare it correctly (you used __stdcall and the function is __cdecl, or vice-versa), or you are accessing an invalid pointer and corrupting the ESP register.
As Paul said, there are 2 possible reasons: either getContract2() is calling a function with a different calling convention, or something in corrupting the stack. The first would be probably easier to spot that the later.
I modified the code a little so that the calling becomes more consistent. I removed reqMktData2. But I still end up getting the same error. It works when I keep either one of them, but not both. This is what I did.
I modified the code a little so that the calling becomes more consistent. I removed reqMktData2. But I still end up getting the same error. It works when I keep either one of them, but not both. This is what I did.
Sorry, but again, your code does not help.
First, things like this:
Code:
(more code)
littered within your post creates more questions. We don't know what you're doing in the (more code), and could be a cause for the whole issue. Secondly, you are calling functions which we have no idea what they are doing (bufferedSend() for example).
Secondly and most important, unless the program is a toy program, runtime problems cannot be solved by looking at pieces of code. To solve a runtime problem, the person trying to solve the problem must have something to run. We don't have your entire code, so unless you post everything, then it's up to you to solve the problem yourself.
The reason for the error is again, those functions are declared with the wrong calling convention, or your program has corrupted the stack. There are no other reasons.
Which functions have the wrong or incorrect calling conventions -- we don't know, you need to find out. If there is stack corruption, you need to debug your program to see if you are making illegal pointer accesses, passing non-NULL (but illegal) pointers, etc.
Bookmarks