Microsoft KB Archive/271208

= BUG: You experience a crash in Mfc42 (d).dll during process exit on Windows 95, Windows 98, or Windows Me =

Article ID: 271208

Article Last Modified on 4/29/2005

-

APPLIES TO

 Microsoft Visual C++ 6.0 Enterprise Edition, when used with:  Microsoft Windows Millennium Edition

 Microsoft Windows 98 Standard Edition  Microsoft Visual C++ 6.0 Professional Edition, when used with:  Microsoft Windows Millennium Edition

 Microsoft Windows 98 Standard Edition</li></ul> </li> Microsoft Visual C++ 6.0 Standard Edition, when used with:  Microsoft Windows Millennium Edition</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q271208

<div class="symptoms_section">

SYMPTOMS
When a process exits, you may experience a crash in the Mfc42.dll or Mfc42d.dll file on a computer that is running Microsoft Windows 95, Microsoft Windows 98, or Microsoft Windows Millennium (Me).

<div class="cause_section">

CAUSE
The Mfc42(d).dll file assumes it is cleaning up on the main thread and relies on the handle map that is stored into a thread-local storage value for the main thread. If the handle map is missing, Microsoft Foundation Class Library (MFC) may crash.

On a computer that is running Windows 95, Windows 98, or Windows Me, you can run DLL_PROCESS_DETACH on any thread, rather than the thread that called the ExitProcess function. (Microsoft Windows NT and Microsoft Windows 2000 exit the process on the thread that called ExitProcess.)

<div class="resolution_section">

RESOLUTION
Use the static MFC library and not the shared MFC dynamic-link library (DLL).

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.

<div class="moreinformation_section">

Steps to reproduce the behavior
<ol> Create a new MFC project and accept all the defaults.</li>  Use class wizard to add a new handler for ID_FILE_OPEN in the CWinApp-derived class. Edit the code to read as follows: void CAssertApp::OnFileOpen {       CFileDialog dlg(TRUE); dlg.DoModal; ASSERT(FALSE); }                   </li> In the message map in the Assert.cpp file, remove the line that maps ID_FILE_OPEN to the CWinApp::OnFileOpen function.</li> Build the debug configuration.</li> Press F5 (on the Debug menu, and then click Go).</li> In the application, click the toolbar button to open a file.</li> Click Cancel in the Open File dialog box.

The assertion is hit and a dialog box titled Debug Assertion Failed! is displayed.</li> Click Abort.</li></ol>

This is known to crash on Windows 98 Second Edition.

Keywords: kbtshoot kbbug KB271208

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.