"The value of ESP was not properly saved across a function call. ..."错误的解决方法

fhchina 2002-04-27 14:43
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 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.

(Press Retry
fhchina 2002-04-27 14:49
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 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.

(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 2002-04-28 02:09
Maybe you need rebuild all your files of the projects.
fhchina 2002-04-28 06:52
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 2002-11-06 11:37
thank you very much. u saved me from a lot of trouble. thanx again
Parthasarathy 2003-07-05 19:20
Great!! , i also have the same probs, but u guys are saved me...
thanks lot.
Jeffrey Magder 2003-07-08 21:53
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 investigation, I changed one of the lines to:

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 as:

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 2003-08-21 23:25
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 2003-08-21 23:25
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
Jagadish Kumar 2003-12-16 02:17
Hi,

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

Cheers,
Jagadish
Christian Posta 2004-11-23 01:27
Thanks a lot, you really saved me a lot of frustration by adding the WINAPI signature word!!
Pasi 2004-12-16 12:49
This really helped me a lot! Thank you very much! The word I was missing was CALLBACK. :)
Dilshan Jesook 2005-01-03 15:47
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 2005-03-09 14:55
Thak you very much, I had exactly the same error.

Thanks.
Daniel Paredes 2005-04-29 18:37
Thank you very much. I was having the same error and it was solved when I added the WINAPI word.

Regards
Apophys 2005-05-18 19:21
Thanks a lot guys! The answer really helped!

You saved me from a lot of trouble!
Jimmy Laenen 2005-05-18 20:05
Jeffrey Magder YOU ARE THE MAN!!

Thanks for your post it helped me out big time
Ben 2004-04-16 11:14
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 2003-01-21 16:46
I just got that message last night- what did you do to fix it? I'm hoping to not have to reformat
KMP 2003-03-11 21:26
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 2003-04-01 08:40
I came across 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 2003-03-11 21:26
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 2003-12-09 22:49
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 2003-10-28 12:04
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
Stephanie ENGRAND 2004-03-25 23:51
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évin Kadri 2004-11-13 10:04
email me
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值