debug error

Discussion in 'C Programming' started by Tiza Naziri, Mar 28, 2005.

  1. Tiza Naziri

    Tiza Naziri Guest

    Hi,

    Can anybody explain to me why this error occurs (during execution in
    MVC++):

    Debug Error!

    Program: C:\..(my code name)
    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)

    Regards,

    -- tiZa Naziri --
    Tiza Naziri, Mar 28, 2005
    #1
    1. Advertising

  2. Tiza Naziri wrote:
    > Can anybody explain to me why this error occurs (during execution in
    > MVC++):

    [...]
    > 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.


    This is a bit outside the scope of plain C, but rather an implementation
    detail. There are different ways to call a function. These mainly differ
    in how things are stored on the stack and by whom, i.e. last argument
    first vs last argument last, caller cleans stack vs callee cleans stack,
    things that are passed in registers(ESP is one such register). This is
    called the 'calling convention' of a function.

    Under win32, different calling conventions are in use, which you can
    specify with prefixes to your function declarations or compiler settings.
    If you call one function with the compiler believing it was convention X
    but implement the function with convention Y, you get above error (if
    you're lucky!).
    So, double check these:
    - when mixing C and C++, make sure all plain C functions are declared
    'extern "C"' for the C++ compiler (and only for that compiler make sure
    via 'defined(__cplusplus)' and the preprocessor.
    - when compiling, make sure the implementation file also includes the
    header where the functions are declared, so you can't have any divergences
    between the two. This is a good idea anyways.
    - with your compiler, you can select the default calling convention which
    is used for functions not otherwise marked. Make sure these match between
    different compilation units.
    - when using function pointers, the calling convention is in fact part of
    the type of that function.

    In case you have further questions about your particular calling
    conventions or your compiler, please first consult the documentation and
    then ask in a group dedicated to your compiler. While the general problem
    is affecting every implementation of C, its details are still not suitable
    for discussion here.

    cheers

    Uli
    Ulrich Eckhardt, Mar 28, 2005
    #2
    1. Advertising

  3. On 28 Mar 2005 00:35:56 -0800, in comp.lang.c , "Tiza Naziri"
    <> wrote:

    >Hi,
    >
    >Can anybody explain to me why this error occurs (during execution in
    >MVC++):


    You've provided the wrong sort of information. Compile your programme
    in debug mode, step through it, and identify where the error arises.

    >File i386\chkesp.c


    Note that this is some system module. The error occurred somewhere
    completely different but only showed up here. Its like falling off a
    cliff - the error was to step off, but the problem only shows up when
    you strike the ground further down...


    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
    Mark McIntyre, Mar 28, 2005
    #3
  4. > Note that this is some system module. The error occurred
    > somewhere completely different but only showed up here. Its
    > like falling off a cliff - the error was to step off, but the
    > problem only shows up when you strike the ground further
    > down...


    I like that description. Mind if I gank it for future use?

    _________________
    Steven K. Mariner

    http://home.earthlink.net/~marinersk/
    http://www.whirlyjigmusic.com/
    Steven K. Mariner, Mar 28, 2005
    #4
  5. On 28 Mar 2005 11:25:02 -0800, in comp.lang.c , "Steven K. Mariner"
    <> wrote:

    > > Note that this is some system module. The error occurred
    > > somewhere completely different but only showed up here. Its
    > > like falling off a cliff - the error was to step off, but the
    > > problem only shows up when you strike the ground further
    > > down...

    >
    >I like that description. Mind if I gank it for future use?


    Feel free. I got it from a lecturer about 25 years ago...


    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

    ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
    ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
    Mark McIntyre, Mar 28, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RonL
    Replies:
    0
    Views:
    716
  2. ringos75
    Replies:
    0
    Views:
    929
    ringos75
    Apr 14, 2005
  3. Mike C. Fletcher
    Replies:
    3
    Views:
    965
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Oct 12, 2003
  4. André
    Replies:
    3
    Views:
    1,553
  5. SÁRINGER Zoltán

    JET error in interdev debug only (DCOM error?)

    SÁRINGER Zoltán, Aug 30, 2004, in forum: ASP General
    Replies:
    7
    Views:
    189
    Jeff Dillon
    Sep 2, 2004
Loading...

Share This Page