none
debug assertion failed

    Question

  • Hi i have developed an application vc++6.
    The application works fine on my pc.
    I took the project ran the project on a different pc(visual studio6 installed).
    It crashes, giving error:debug assertion failed.
    However when i debug the project on that pc ,it works fine.

    I don'nt know how to solve this .
    Can any body help me?
    thanks
    Monday, April 20, 2009 2:47 PM

Answers

  • const CString& CString::operator=(LPCTSTR lpsz)
    {
    ASSERT(lpsz == NULL || AfxIsValidString(lpsz));


    so it would seem that you are assigning a null pointer to a CString, or you are passing a bogus pointer


    Click Retry, attach your debugger, and check your call-stack to see what was happening at the time.
    • Marked as answer by Nancy Shao Monday, April 27, 2009 2:01 AM
    Monday, April 20, 2009 3:51 PM
  • Assertion checking is turned off by defining the identifier NDEBUG. NDEBUG can be defined with a /D command-line option (Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions) or with a #define directive before ASSERT.H is included.
    • Marked as answer by Nancy Shao Monday, April 27, 2009 2:01 AM
    Monday, April 20, 2009 4:08 PM

All replies

  • (much) more info please.  1st: What is the assertion message?
    Monday, April 20, 2009 3:35 PM
  • the message is
    "
    Debud assertion failed

    program: f:\bin\MyApp.exe
    File :  strcore.cpp
    line : 344

    For more information on how  your program can cause  an assertion failure...........
    (press retry to debug the application)

    "

    Monday, April 20, 2009 3:43 PM
  • const CString& CString::operator=(LPCTSTR lpsz)
    {
    ASSERT(lpsz == NULL || AfxIsValidString(lpsz));


    so it would seem that you are assigning a null pointer to a CString, or you are passing a bogus pointer


    Click Retry, attach your debugger, and check your call-stack to see what was happening at the time.
    • Marked as answer by Nancy Shao Monday, April 27, 2009 2:01 AM
    Monday, April 20, 2009 3:51 PM
  • thanks for replying,

    but how is that the  exe runs fine when i debug it.
    (does'nt show debug error)
    Monday, April 20, 2009 3:56 PM
  • Assertion checking is turned off by defining the identifier NDEBUG. NDEBUG can be defined with a /D command-line option (Configuration Properties > C/C++ > Preprocessor > Preprocessor Definitions) or with a #define directive before ASSERT.H is included.
    • Marked as answer by Nancy Shao Monday, April 27, 2009 2:01 AM
    Monday, April 20, 2009 4:08 PM
  • can you  let me know how to turn on assertion check in debug
    Monday, April 20, 2009 4:28 PM
  • #undef  NDEBUG    before assert.h is inluded.
    Monday, April 20, 2009 4:56 PM
  • the message is
    "
    Debud assertion failed

    program: f:\bin\MyApp.exe
    File :  strcore.cpp
    line : 344

    For more information on how  your program can cause  an assertion failure...........
    (press retry to debug the application)

    "

    but how is that the exe runs fine when i debug it.
    (does'nt show debug error)
    Now you've really confused me!   How did you see the assertion message that says "press retry to debug the application"???

    Do whatever you did to get the assertion message to appear, then just click retry and when it asks you to choose a debugger, open it in visual studio and look at your call stack. 

    Assertions don't fire in release mode, so I'm pretty sure you have built debug mode code.  But are just running it outside of the debugger.  You can run your program outside of the debugger, then attach a debugger to the process after the assertion failure dialog box pops up.


    Monday, April 20, 2009 6:00 PM
  • Is the release version works fine?

    What is the code at line : 344 of strcore.cpp?

    One more thing.
    Attach the debugger and run the application using F5 (no break points). Is the crash happening?
    Thursday, April 23, 2009 1:46 PM
  • Albin Baby, I have already posted the code at strcore.cpp(344).  It's CString::operator=

    Which should be the same on your machine, btw.
    Thursday, April 23, 2009 3:15 PM