Click here to Skip to main content
11,928,740 members (50,812 online)
Rate this:
Please Sign up or sign in to vote.
See more: VS2008 C++ Visual-Studio MFC , +
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 ?

Posted 1-Aug-12 4:43am
Edited 1-Aug-12 6:24am
nv3 1-Aug-12 11:20am
Did you mean "... but the debugger didn't stop on the assert"?
Maximilien 1-Aug-12 11:24am
oh !!!! yes! ( I will edit the original posts!!) thanks for that.
armagedescu 2-Aug-12 6:12am
If ASSERT_VALID fails, then expression inside is invalid. So, check why is it invalid.
Maximilien 2-Aug-12 7:16am

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.
armagedescu 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
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
Maximilien 1-Aug-12 10:49am
Well the ASSERT_VALID does not stop the debugger, that is why I'm asking the question.
Albert Holguin 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 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 1-Aug-12 11:44am
Yes, will have to look into that.


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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 1 Aug 2012
Copyright © CodeProject, 1999-2015
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