DLL call error-the value of ESP was not properly saved stored ss a function call.

Source: Internet
Author: User

When you call a function in a DLL, the following dialog box is displayed:

Microsoft Visual C ++ debug Library:

Debug error:
Program :...
Module:
File: i386/chkesp. c
Line: 42

The value of ESP was not properly saved stored ss 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.

(Press retry to debug the Application)

One of the solutions is:

Add winapi before function callFor more information, see the following excerpt.

From http://www.opencascade.org/org/forum/thread_2812/

Help! Calling convention error!
Fhchina | Reply
Please help me! I encounter the such 'splendid' error at runtime:

Microsoft Visual C ++ debug Library:

Debug error:
Program :...
Module:
File: i386/chkesp. c
Line: 42

The value of ESP was not properly saved stored ss 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.

(Press retry

Fhchina | Reply
Sorry, misclick the mouse, the following is the correct message.

Please help me! I encounter the such 'splendid' error at runtime:

Microsoft Visual C ++ debug Library:

Debug error:
Program :...
Module:
File: i386/chkesp. c
Line: 42

The value of ESP was not properly saved stored ss 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.

(Press retry to debug the Application)

Then press retry to debug it, each time I found my program abort at the following code:

/////////////////////////
// Aline is a pointer of ais_line.
Handle (geom_point) hstart, HEND;
Aline-> points (hstart, HEND );

Topods_edge aedge = brepbuilderapi_makeedge (hstart-> pnt (), HEND-> pnt ());

Each time the call stack will show the program abort on the final line. Why?
I think I shouldn't consider any calling convention as an application developer. and this segment is runing very well before I introduce ocaf into my application. and I have checked all the compiler options, it seems no problem. please help me!

Lugi. c | Reply
Maybe you need rebuild all your files of the projects.
Fhchina | Reply
Thanks for your response. I have solved the problem last night. but before report this error I have rebuild all of my files include both debug & release version. the error still exists, even I turned off/GZ option. and I have found some similar posts on the Internet by Google, but there is no statisfactory solution or explanation. as far as my experience for this error, it usually a logic error of code. and I guess this kind of logic error cause this ESP register check error. (The concrete reason is still unknown), but it must not be the calling convention mismatch.
Manoj vithanage | Reply
Thank you very much. U saved me from a lot of trouble. thanx again
Parthasarathy | Reply
Great !! , I also have the same probs, but u guys are saved me...
Thanks lot.
Jeffrey magder | Reply
I was having the same problem, but I just fixed it. I was getting the same error from the following code:

Hmodule hpowerfunctions = loadlibrary ("powrprof. dll ");
Typedef bool (* tsetsuspendstatesig) (bool, bool, bool );

Tsetsuspendstate setsuspendstate = (tsuspendstatesig) getprocaddress (hpowerfunctions, "setsuspendstate ");

Result = setsuspendstate (false, false, false); <---- this line was where the error popped up.

After some investors, I changed one of the lines:

Typedef bool (winapi * tsetsuspendstatesig) (bool, bool, bool );

Which solved the problem. If you take a look in the header file where setsuspendstate is found (powrprof. H, part of the SDK), you will see the function prototype is defined:

Boolean winapi setsuspendstate (Boolean, Boolean, Boolean );

So you guys are having a similar problem. When you are calling a given function from a. dll, its signature is probably off. (in my case it was the missing winapi keyword ).

Hope that helps any future people!

Cheers.

Dheeraj | Reply
Hi,

I was alos getting the same kind of error. I have tried what way U suggested in a function pointer. I have added winapi to a function pointer and my program worked.

Thanks for the such information which helped me.

Dheeraj | Reply
Hi,

I was alos getting the same kind of error. I have tried what way U suggested in a function pointer. I have added winapi to a function pointer and my program worked.

Thanks for the such information which helped me.

Hope to get more information of such nature.

Cheers

Jaradish Kumar | Reply
Hi,

I was having the same problem. It got fixed with your solution. thanx a lot. It really saved a lot of time.

Cheers,
Jaradish

Christian Posta | Reply
Thanks a lot, you really saved me a lot of frustration by adding the winapi signature word !!
Pasi | Reply
This really helped me a lot! Thank you very much! The word I was missing was callback.
Dilshan jesook | Reply
I was having this same problem with that stupid runtime error allways poping up, and solved it by typing in the winapi keyword... problem solved. Thanks to such forum.
John | Reply
Thak you very much, I had exactly the same error.

Thanks.

Ben | Reply
I have the same problem when I call a function in an ATL DLL from VB.
There is no more error message during runtime when removing/GZ option, however VB generate an exception when I close it...
K | Reply
I just got that message last night-what did you do to fix it? I'm hoping to not have to reformat
KMP | Reply
I'm facing the same problem. and as said, its pointing to the end of a func call. in this function, I have called a funtion pointer that stores the address returned by the API call getprocaddress (). which is inturn usedfor thunking from 32 bits to 16 bits.

Other than removing/GZ, is there any other

Prashant Deshmukh | Reply
I Came authentication SS this debug error message when I was parsing XML using xerces-> Dom parser
It seems to be logical error since
The code worked when I tried
Typcasting direct (domtext *) domnode *
But fails if I am trying to access a method getwholetext () by typcasting like
(Domtext *) (domcharachter) domnode *

Do any body have solution or reason why this is happening ????

KMP | Reply
I'm facing the same problem. and as said, its pointing to the end of a func call. in this function, I have called a funtion pointer that stores the address returned by the API call getprocaddress (). which is inturn usedfor thunking from 32 bits to 16 bits.

Other than removing/GZ, is there any other way out.

Karim Sharif | Reply
In my case it turned out to be an invalid memory
Initlization to zero, which wiped out whatever was
On Stack. All these happend in the DLL which was
Being call from my c ++ program.
Lucia | Reply
Hello,
I have the same error. I found it when I added a bitmap in my FlexGrid. This is my code:

......
Cpictureholder PIC;
PIC. createbitmap (idb_bitmap );
M_grid.setrefcellpicture (PIC. getpicturedispatch );
.....

I, ve seen that the problem is the following: When I call createbitmap or any function of cpictureholder class, my program jump to an incorrect address in mfco42d. DLL, but I don't know why, anyone can help me ?? Thanks

Stefan engrand | Reply
I encounter the same error:
It was because I forgot to put:

Using STD: basic_string;

I hope this help you

(Sorry for my English but I'm French)

K bytes in Kadri | Reply
Email me

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.