Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2008 C++ MFC Debugging , +
Should an ASSERT_VALID stop in the debugger ?
 
I'm trying to trace a crash when our application closes.
 
It crashes somewhere in CFrameWnd::OnClose (in a ::DestroyWindow).
 
In the message log there is a ASSERT_VALID that is logged; but the debugger does NOT stop on the assert:
 
ASSERT_VALID fails with NULL pointer.
 
Not much help that gives me; no code reference (file or line number or allocation number)
 
I tried enabling all the exceptions, but no change.
 
Am I missing something ?
 
Thanks.
Posted 1-Aug-12 3:43am
Edited 1-Aug-12 5:24am
v2
Comments
nv3 at 1-Aug-12 11:20am
   
Did you mean "... but the debugger didn't stop on the assert"?
Maximilien at 1-Aug-12 11:24am
   
oh !!!! yes! ( I will edit the original posts!!) thanks for that.
armagedescu at 2-Aug-12 6:12am
   
If ASSERT_VALID fails, then expression inside is invalid. So, check why is it invalid.
Maximilien at 2-Aug-12 7:16am
   
@armagedescu.
 
I does not break in the debugger, so no call stack.
The report in the meesage area does not show context (line/file/function/method), so I cannot easily find out why it crashes,
anyway, the question was more about the ASSERT_VALID not breaking than debugging.
Thanks.
armagedescu at 3-Aug-12 8:42am
   
ASSERT_VALID will break the execution only if the expression inside is invalid. Anyway, if you build in debug mode, then even invalid expression will not break execution. I suppose you need to look inside ASSERT_VALID, and also look at build mode, debug/release. ASSERT_VALID calls a member function from the provided expression.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This type of crash typically occurs when a frame window or view is being deleted via two separate code paths. For one, these windows normally have a
 
    delete this;
 
in their OnNcDestroy function and de-allocate their object automatically. If it is also accidentally deleted by the user, the mentioned problem occurs.
 
Perhaps that gives you some help with tracing that one down.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Quote:
Should an ASSERT_VALID stop in the debugger ?

Short answer, yes.
 
It won't tell you directly what led to the assertion, but you should be able to look at the call stack and trace back to see what part of your code led to the assertion being triggered.
  Permalink  
Comments
Maximilien at 1-Aug-12 10:49am
   
Well the ASSERT_VALID does not stop the debugger, that is why I'm asking the question.
Albert Holguin at 1-Aug-12 11:38am
   
Oh, I see... I misunderstood... it should stop the debugger. I guess now I see how that's a head scratcher.
Albert Holguin at 1-Aug-12 11:41am
   
Wonder if perhaps you've either overriden the macro or perhaps defined the AssertValid() method in a manner that prevents the usual pop-up.
Maximilien at 1-Aug-12 11:44am
   
Yes, will have to look into that.
 
Thanks,
 
Will report back when I find something useful.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170
0 Nirav Prabtani 284
1 OriginalGriff 217
2 Sergey Alexandrovich Kryukov 196
3 Mika Wendelius 185
4 CPallini 170


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100