Student requires urgent help! Debug Assertion Failed error

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

    Student requires urgent help! Debug Assertion Failed error

    Hi everyone,

    I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
    Windows2000. I'm running motions sensor hardware so there's a bit of
    real time data processing involved.

    When I'm running my objects in Pure Data, I get an assertion failure
    after a few seconds of running the motion sensors and I can't seem to
    get rid of it. The error occurs in the expression _CrtCheckMemory ().
    Could anyone provide some possible solutions?

    Many thanks,
    Cormac
  • Marcin Kalicinski

    #2
    Re: Student requires urgent help! Debug Assertion Failed error

    Uzytkownik "Cormac" <boddah@csn.ul. ie> napisal w wiadomosci
    news:400ce517.0 404060211.59199 ddf@posting.goo gle.com...[color=blue]
    > Hi everyone,
    >
    > I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
    > Windows2000. I'm running motions sensor hardware so there's a bit of
    > real time data processing involved.
    >
    > When I'm running my objects in Pure Data, I get an assertion failure
    > after a few seconds of running the motion sensors and I can't seem to
    > get rid of it. The error occurs in the expression _CrtCheckMemory ().
    > Could anyone provide some possible solutions?[/color]

    You overwrite memory somewhere in your code. _CrtCheckMemory () in debug
    builds of VC++ 7.0 checks the consistency of the heap. Because it asserts -
    the heap is corrupt. The assertion message probably contains more detailed
    information - i.e. where the corruption occured (but not when). In general,
    tracking down this kind of bug is hard, and this is probably one of the
    worst symptoms of bug you can have in C++. It's sometimes called CoreWars
    :-).

    It can be caused by writing outside an array, by using members of object
    that has been deleted (common cause), by deleting object more than once, and
    by multitude of other "undefined behavior" actions that you can do in C++.

    I suggest you quickly review the code that you recently changed to determine
    if you haven't introduced any pointer-related bugs. If it does not help, you
    might try pinpointing down the exact address where the corruption occurs,
    and check the contents of corrupt memory. Usually it will contain rubbish
    (some pointers, floating point numbers etc.). You can try to identify that -
    for example if it is a floating point number or a C string - you may
    succeed. Then, you'll have a clue where to look for corruption source.

    If this fails, you can try setting a memory-access breakpoint in this place
    (Visual C++ 7.0 has this feature in IDE). You'll get debug break anytime the
    memory is changed. By enabling and disabling the breakpoint in "clever" way,
    provided that you have enough patience and time, you may pinpoint the moment
    where the memory is actually corrupt.

    <OT>
    If this fails, switch to Java or C# and rewrite the project :-)
    </OT>

    Good luck,
    Marcin





    Comment

    • Marcin Kalicinski

      #3
      Re: Student requires urgent help! Debug Assertion Failed error

      Uzytkownik "Cormac" <boddah@csn.ul. ie> napisal w wiadomosci
      news:400ce517.0 404060211.59199 ddf@posting.goo gle.com...[color=blue]
      > Hi everyone,
      >
      > I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
      > Windows2000. I'm running motions sensor hardware so there's a bit of
      > real time data processing involved.
      >
      > When I'm running my objects in Pure Data, I get an assertion failure
      > after a few seconds of running the motion sensors and I can't seem to
      > get rid of it. The error occurs in the expression _CrtCheckMemory ().
      > Could anyone provide some possible solutions?[/color]

      You overwrite memory somewhere in your code. _CrtCheckMemory () in debug
      builds of VC++ 7.0 checks the consistency of the heap. Because it asserts -
      the heap is corrupt. The assertion message probably contains more detailed
      information - i.e. where the corruption occured (but not when). In general,
      tracking down this kind of bug is hard, and this is probably one of the
      worst symptoms of bug you can have in C++. It's sometimes called CoreWars
      :-).

      It can be caused by writing outside an array, by using members of object
      that has been deleted (common cause), by deleting object more than once, and
      by multitude of other "undefined behavior" actions that you can do in C++.

      I suggest you quickly review the code that you recently changed to determine
      if you haven't introduced any pointer-related bugs. If it does not help, you
      might try pinpointing down the exact address where the corruption occurs,
      and check the contents of corrupt memory. Usually it will contain rubbish
      (some pointers, floating point numbers etc.). You can try to identify that -
      for example if it is a floating point number or a C string - you may
      succeed. Then, you'll have a clue where to look for corruption source.

      If this fails, you can try setting a memory-access breakpoint in this place
      (Visual C++ 7.0 has this feature in IDE). You'll get debug break anytime the
      memory is changed. By enabling and disabling the breakpoint in "clever" way,
      provided that you have enough patience and time, you may pinpoint the moment
      where the memory is actually corrupt.

      <OT>
      If this fails, switch to Java or C# and rewrite the project :-)
      </OT>

      Good luck,
      Marcin





      Comment

      • Thomas Matthews

        #4
        Re: Student requires urgent help! Debug Assertion Failed error

        Cormac wrote:
        [color=blue]
        > Hi everyone,
        >
        > I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
        > Windows2000. I'm running motions sensor hardware so there's a bit of
        > real time data processing involved.
        >
        > When I'm running my objects in Pure Data, I get an assertion failure
        > after a few seconds of running the motion sensors and I can't seem to
        > get rid of it. The error occurs in the expression _CrtCheckMemory ().
        > Could anyone provide some possible solutions?
        >
        > Many thanks,
        > Cormac[/color]

        My crystal ball says that your problem is on line 123 in the
        third source file. Fix that and all shall be well.

        Since my crystal ball may be wrong, post the minimal compilable and
        executable source code that recreates the problem. Other than that
        try using "print" statements to see where the memory leak is.

        --
        Thomas Matthews

        C++ newsgroup welcome message:

        C++ Faq: http://www.parashift.com/c++-faq-lite
        C Faq: http://www.eskimo.com/~scs/c-faq/top.html
        alt.comp.lang.l earn.c-c++ faq:

        Other sites:
        http://www.josuttis.com -- C++ STL Library book

        Comment

        • Thomas Matthews

          #5
          Re: Student requires urgent help! Debug Assertion Failed error

          Cormac wrote:
          [color=blue]
          > Hi everyone,
          >
          > I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
          > Windows2000. I'm running motions sensor hardware so there's a bit of
          > real time data processing involved.
          >
          > When I'm running my objects in Pure Data, I get an assertion failure
          > after a few seconds of running the motion sensors and I can't seem to
          > get rid of it. The error occurs in the expression _CrtCheckMemory ().
          > Could anyone provide some possible solutions?
          >
          > Many thanks,
          > Cormac[/color]

          My crystal ball says that your problem is on line 123 in the
          third source file. Fix that and all shall be well.

          Since my crystal ball may be wrong, post the minimal compilable and
          executable source code that recreates the problem. Other than that
          try using "print" statements to see where the memory leak is.

          --
          Thomas Matthews

          C++ newsgroup welcome message:

          C++ Faq: http://www.parashift.com/c++-faq-lite
          C Faq: http://www.eskimo.com/~scs/c-faq/top.html
          alt.comp.lang.l earn.c-c++ faq:

          Other sites:
          http://www.josuttis.com -- C++ STL Library book

          Comment

          • Kevin Goodsell

            #6
            Re: Student requires urgent help! Debug Assertion Failed error

            Cormac wrote:
            [color=blue]
            > Hi everyone,
            >
            > I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
            > Windows2000. I'm running motions sensor hardware so there's a bit of
            > real time data processing involved.
            >
            > When I'm running my objects in Pure Data, I get an assertion failure
            > after a few seconds of running the motion sensors and I can't seem to
            > get rid of it. The error occurs in the expression _CrtCheckMemory ().
            > Could anyone provide some possible solutions?
            >[/color]

            Short answer: You should have used standard containers instead of 'new'
            (although this can also happen if you mis-use containers -- a good
            debugging version of the standard containers helps).

            Explicit memory management is a bitch, and debugging the problems that
            arise from it is even worse.

            -Kevin
            --
            My email address is valid, but changes periodically.
            To contact me please use the address from a recent posting.

            Comment

            • Kevin Goodsell

              #7
              Re: Student requires urgent help! Debug Assertion Failed error

              Cormac wrote:
              [color=blue]
              > Hi everyone,
              >
              > I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and
              > Windows2000. I'm running motions sensor hardware so there's a bit of
              > real time data processing involved.
              >
              > When I'm running my objects in Pure Data, I get an assertion failure
              > after a few seconds of running the motion sensors and I can't seem to
              > get rid of it. The error occurs in the expression _CrtCheckMemory ().
              > Could anyone provide some possible solutions?
              >[/color]

              Short answer: You should have used standard containers instead of 'new'
              (although this can also happen if you mis-use containers -- a good
              debugging version of the standard containers helps).

              Explicit memory management is a bitch, and debugging the problems that
              arise from it is even worse.

              -Kevin
              --
              My email address is valid, but changes periodically.
              To contact me please use the address from a recent posting.

              Comment

              Working...