debug error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tiza Naziri

    #1

    debug error

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

  • Ulrich Eckhardt

    #2
    Re: debug error

    Tiza Naziri wrote:[color=blue]
    > Can anybody explain to me why this error occurs (during execution in
    > MVC++):[/color]
    [...][color=blue]
    > 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.[/color]

    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(__cplu splus)' 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

    Comment

    • Mark McIntyre

      #3
      Re: debug error

      On 28 Mar 2005 00:35:56 -0800, in comp.lang.c , "Tiza Naziri"
      <watija@yahoo.c om> wrote:
      [color=blue]
      >Hi,
      >
      >Can anybody explain to me why this error occurs (during execution in
      >MVC++):[/color]

      You've provided the wrong sort of information. Compile your programme
      in debug mode, step through it, and identify where the error arises.
      [color=blue]
      >File i386\chkesp.c[/color]

      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 >

      Comment

      • Steven K. Mariner

        #4
        Re: debug error

        > Note that this is some system module. The error occurred[color=blue]
        > 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...[/color]

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

        _______________ __
        Steven K. Mariner
        marinersk@earth link.net



        Comment

        • Mark McIntyre

          #5
          Re: debug error

          On 28 Mar 2005 11:25:02 -0800, in comp.lang.c , "Steven K. Mariner"
          <marinersk@eart hlink.net> wrote:
          [color=blue][color=green]
          > > 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...[/color]
          >
          >I like that description. Mind if I gank it for future use?[/color]

          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 =----

          Comment

          Working...