1. Callback error
- Posted by Matthew Lewis <MatthewL at KAPCOUSA.COM> Nov 02, 1999
- 557 views
Hi, As I'd mentioned earlier, I'm working on a DLL for use with Euphoria. I figured out how to get the callback, and how to call my euphoria function. However, I get an error when my program returns to the DLL. I have MS Visual C++ 6, and the error that pops up is: -- Start error report Program: C:\EUPHORIA\BIN\EXW.EXE Module: File: i386\chkesp.c Line 42 The value of ESP was not properly saved across a function call. This is usually the result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. -- End error report I've declared my function pointer as: int (*EuCallBack)(int, int) It passes values to my euphoria routine just fine, but crashes when it comes back. My function returns 1. (I've also tried long (*EuCallBack)(int, int), and I got the same error.) Do I need to do something special to return to the DLL? Maybe use __stdcl* instead of the default __cdecl*? I have no idea what i386\chkesp.c or ESP might be. Hopefully this makes sense to someone out there (Rob?)... Matthew W Lewis
2. Re: Callback error
- Posted by "Lucius L. Hilley III" <lhilley at CDC.NET> Nov 02, 1999
- 600 views
ESP - Extra Sensory Perception. The computer is trying to guess what you wanted to do but failed. o<8^) :) Okay, ESP - The Extended Stack Pointer. - Stack Pointer for a program running it protected memory. ESP is a system Register. Similar to EAX, EBX, ECX, EDX, EBP. These are low level assembly/machine code values. This means that your Stack Pointer was corrupted. You either failed to return when you should have or return the values to their original state before returning. An other possibilities can be covered by our resident ASM geeks such as Pete Eberlein. Lucius L. Hilley III lhilley at cdc.net lucius at ComputerCafeUSA.com +----------+--------------+--------------+----------+ | Hollow | ICQ: 9638898 | AIM: LLHIII | Computer | | Horse +--------------+--------------+ Cafe' | | Software | http://www.cdc.net/~lhilley | USA | +----------+-------+---------------------+----------+ | http://www.ComputerCafeUSA.com | +--------------------------------+ ----- Original Message ----- From: Matthew Lewis <MatthewL at KAPCOUSA.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Tuesday, November 02, 1999 11:01 AM Subject: Callback error > ---------------------- Information from the mail header ----------------------- > Sender: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> > Poster: Matthew Lewis <MatthewL at KAPCOUSA.COM> > Subject: Callback error > -------------------------------------------------------------------------- ----- > > Hi, > > As I'd mentioned earlier, I'm working on a DLL for use with Euphoria. I > figured out how to get the callback, and how to call my euphoria function. > However, I get an error when my program returns to the DLL. I have MS > Visual C++ 6, and the error that pops up is: > > -- Start error report > Program: C:\EUPHORIA\BIN\EXW.EXE > Module: > File: i386\chkesp.c > Line 42 > The value of ESP was not properly saved across a function call. This is > usually the result of calling a function declared with one calling > convention with a function pointer declared with a different calling > convention. > -- End error report > > I've declared my function pointer as: > > int (*EuCallBack)(int, int) > > It passes values to my euphoria routine just fine, but crashes when it comes > back. My function returns 1. (I've also tried long (*EuCallBack)(int, > int), and I got the same error.) Do I need to do something special to > return to the DLL? Maybe use __stdcl* instead of the default __cdecl*? I > have no idea what i386\chkesp.c or ESP might be. > > Hopefully this makes sense to someone out there (Rob?)... > > Matthew W Lewis >
3. Re: Callback error
- Posted by Bernie Ryan <bwryan at PCOM.NET> Nov 02, 1999
- 529 views
Switching to a local stack inside your dll might help . Are you aware that vel uses a DLL maybe you should find out how they handle that stack. Bernie
4. Re: Callback error
- Posted by Robert Craig <rds at ATTCANADA.NET> Nov 02, 1999
- 527 views
- Last edited Nov 03, 1999
Matthew Lewis writes: > int (*EuCallBack)(int, int) > It passes values to my euphoria routine just fine, but > crashes when it comes back. My function returns 1. > (I've also tried long (*EuCallBack)(int, int), and I got > the same error.) Do I need to do something special > to return to the DLL? Maybe use __stdcl* instead > of the default __cdecl*? Try using __stdcall or __stdcl, whatever your compiler defines for "standard call". It's the calling convention that's used when a WIN32 API routine is called. The default calling convention is __cdecl. There's a difference in the way the call stack is cleaned up after a call. That's probably why you had a problem. __cdecl allows for a variable number of arguments to be passed, but the caller is responsible for cleaning up the stack. With __stdcall, the subroutine cleans up the stack since it "knows" how many arguments must have been passed. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
5. Re: Callback error
- Posted by Matthew Lewis <MatthewL at KAPCOUSA.COM> Nov 03, 1999
- 531 views
Thanks for all the suggestions. Unfortunately, none of them seemed to work (at least, I couldn't make it happen.) Fortunately, I sidestepped the issue by passing a pointer and letting the C routines store the data I needed passed there. This seems to work fine. I'd be interested to know if anyone else (esp Gary Dumer with VEL, even though its not written in C) has had a similar problem? BTW, the project I'm working on is using CLIPS, which is a C based expert system development language, created by NASA. I recall Ralf talking about interest in Lisp or Prolog or something with regard to creating an inference engine in Euphria. That's exactly what CLIPS is about. There are several sites on the web from which to download versions of CLIPS, including the source (it's all PD). The CLIPS homepage is at: http://www.ghgcorp.com/clips/CLIPS.html if anyone's interested... Matthew W Lewis