Twice entering ASSERT failure
mark -- mark@radmail.rad.co.il
Wednesday, January 29, 1997
Twice entering ASSERT failure.
-------------------------------------------------
Environment: VC++ 4.2-flat, Win 95
We've installed VC++ 4.2 and have got a new headache.
The problem didn't exist in VC++ 4.0 but appeared in VC++ 4.2. It is seemed
connected to new version of msvcrtd.dll which is used by mfc42d.dll.
We send two or more messages to a window of application. In code of message
handler we call macro ASSERT(FALSE ). The first message received by application
causes Assert Message Box is open. So the second message enters the handler and
calls ASSERT before the first one is finished. As result the application fails with
message "an illegal operation" detailed as "an exception 03H in module KERNEL32.DLL
at 0137:bff76694."
or under debug with call stack :
================================
KERNEL32! bff76693()
_CrtDbgReport(int 2, char * 0x004056e0, int 35, char * 0x00000000, char * 0x00000000)
line 353
AfxAssertFailedLine(char * 0x004056e0, int 35) line 39 + 20 bytes
CAaView::OnTest(unsigned int 0, unsigned int 0) line 35 + 12 bytes
CWnd::OnWndMsg(unsigned int 1124, unsigned int 0, long 0, long * 0x0063b42c) line
1733 + 17 bytes
CWnd::WindowProc(unsigned int 1124, unsigned int 0, long 0) line 1522 + 30 bytes
================================
To build a sample demonstrated the problem we use application Aa buit by Application
Wizard adding item "TestAssert" to its menu. The following code was added to
Aaview.cpp
====================================
#define MM_TEST WM_USER +100
BEGIN_MESSAGE_MAP(CAaView, CView)
//{{AFX_MSG_MAP(CAaView)
ON_COMMAND(ID_Assert, OnTestAssert)
ON_MESSAGE( MM_TEST, OnTest)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAaView::OnTestAssert()
{
PostMessage( MM_TEST, 0,0);
}
afx_msg LONG CAaView::OnTest( UINT, LONG )
{
static int nCount =0;
if( nCount++ < 10 )
{
PostMessage( MM_TEST, 0,0);
ASSERT(FALSE);
}
else
nCount =0;
return 0;
}
====================================
Could somebody explain what happened ?
Mark Appel
Leo PL -- wul@PO5.pl.unisys.com
Thursday, January 30, 1997
[Mini-digest: 2 responses]
Small suggestions :
1. Will you try to see return of PostMessage is true or false?
2. Are you trying to ASSERT FALSE? instead TRUE?
Z. Leo Wu
----------
Twice entering ASSERT failure.
-------------------------------------------------
Environment: VC++ 4.2-flat, Win 95
We've installed VC++ 4.2 and have got a new headache.
The problem didn't exist in VC++ 4.0 but appeared in VC++ 4.2. It is
seemed
connected to new version of msvcrtd.dll which is used by mfc42d.dll.
We send two or more messages to a window of application. In code of
message
handler we call macro ASSERT(FALSE ). The first message received by
application
causes Assert Message Box is open. So the second message enters the
handler and
calls ASSERT before the first one is finished. As result the application
fails with
message "an illegal operation" detailed as "an exception 03H in module
KERNEL32.DLL
at 0137:bff76694."
or under debug with call stack :
================================
KERNEL32! bff76693()
_CrtDbgReport(int 2, char * 0x004056e0, int 35, char * 0x00000000, char *
0x00000000)
line 353
AfxAssertFailedLine(char * 0x004056e0, int 35) line 39 + 20 bytes
CAaView::OnTest(unsigned int 0, unsigned int 0) line 35 + 12 bytes
CWnd::OnWndMsg(unsigned int 1124, unsigned int 0, long 0, long *
0x0063b42c) line
1733 + 17 bytes
CWnd::WindowProc(unsigned int 1124, unsigned int 0, long 0) line 1522 + 30
bytes
================================
To build a sample demonstrated the problem we use application Aa buit by
Application
Wizard adding item "TestAssert" to its menu. The following code was added
to
Aaview.cpp
====================================
#define MM_TEST WM_USER +100
BEGIN_MESSAGE_MAP(CAaView, CView)
//{{AFX_MSG_MAP(CAaView)
ON_COMMAND(ID_Assert, OnTestAssert)
ON_MESSAGE( MM_TEST, OnTest)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CAaView::OnTestAssert()
{
PostMessage( MM_TEST, 0,0);
}
afx_msg LONG CAaView::OnTest( UINT, LONG )
{
static int nCount =0;
if( nCount++ < 10 )
{
PostMessage( MM_TEST, 0,0);
ASSERT(FALSE);
}
else
nCount =0;
return 0;
}
====================================
Could somebody explain what happened ?
Mark Appel
-----From: Gonzalo Isaza
Actually the code should have always worked as it does now. Due to a
bug in the CRT this code was not working correctly. The behavior is
trying to prevent an ASSERT to be handled normally while an ASSERT is
taking place to prevent infinite recursion type of thing. Issuing an
int 3 during the second assert prevents this infinite recursion. For
some debugging situaltions it is beneficial to totally stop the process
when an assert occurs. This is not the case with a single ASSERT being
processed (in a hypothetical case you could create a timer that waits
for assert dialogs and dismiss them automatically, because messages are
still being processed while the assert is up).
There is big room for discussion on how this feature should work, and
both sides will probably have valid arguments. The initial design was
for the code to stop on nested ASSERT's, but a bug in the code prevented
this from working. The bug was fixed in version 4.2, and so, the
behavior now is what it was always intended to be.
Gonzalo
PS: I speak for myself. I do not speak in behalf of Microsoft.
>----------
>From: mark@radmail.rad.co.il[SMTP:mark@radmail.rad.co.il]
>Sent: Tuesday, January 28, 1997 10:27 PM
>To: mfc-l
>Subject: Twice entering ASSERT failure
>
>Twice entering ASSERT failure.
>-------------------------------------------------
>Environment: VC++ 4.2-flat, Win 95
>
>We've installed VC++ 4.2 and have got a new headache.
>The problem didn't exist in VC++ 4.0 but appeared in VC++ 4.2. It is seemed
>connected to new version of msvcrtd.dll which is used by mfc42d.dll.
>We send two or more messages to a window of application. In code of
>message
>handler we call macro ASSERT(FALSE ). The first message received by
>application
>causes Assert Message Box is open. So the second message enters the
>handler and
>calls ASSERT before the first one is finished. As result the application
>fails with
>message "an illegal operation" detailed as "an exception 03H in module
>KERNEL32.DLL
>at 0137:bff76694."
>or under debug with call stack :
>================================
>KERNEL32! bff76693()
>_CrtDbgReport(int 2, char * 0x004056e0, int 35, char * 0x00000000, char *
>0x00000000)
>line 353
>AfxAssertFailedLine(char * 0x004056e0, int 35) line 39 + 20 bytes
>CAaView::OnTest(unsigned int 0, unsigned int 0) line 35 + 12 bytes
>CWnd::OnWndMsg(unsigned int 1124, unsigned int 0, long 0, long * 0x0063b42c)
>line
>1733 + 17 bytes
>CWnd::WindowProc(unsigned int 1124, unsigned int 0, long 0) line 1522 + 30
>bytes
>================================
>To build a sample demonstrated the problem we use application Aa buit by
>Application
>Wizard adding item "TestAssert" to its menu. The following code was added to
>Aaview.cpp
>====================================
>#define MM_TEST WM_USER +100
>
>BEGIN_MESSAGE_MAP(CAaView, CView)
> //{{AFX_MSG_MAP(CAaView)
> ON_COMMAND(ID_Assert, OnTestAssert)
> ON_MESSAGE( MM_TEST, OnTest)
> //}}AFX_MSG_MAP
>END_MESSAGE_MAP()
>
>void CAaView::OnTestAssert()
>{
> PostMessage( MM_TEST, 0,0);
>}
>
>afx_msg LONG CAaView::OnTest( UINT, LONG )
>{
> static int nCount =0;
> if( nCount++ < 10 )
> {
> PostMessage( MM_TEST, 0,0);
> ASSERT(FALSE);
> }
> else
> nCount =0;
> return 0;
>}
>====================================
>
> Could somebody explain what happened ?
> Mark Appel
>
| Вернуться в корень Архива
|