Microsoft KB Archive/256056
Article ID: 256056
Article Last Modified on 11/21/2006
- Microsoft Foundation Class Library 4.2, when used with:
- Microsoft Visual C++ 5.0 Standard Edition
- Microsoft Visual C++ 6.0 Service Pack 5
This article was previously published under Q256056
The DllMain code in MFC throws an unhandled exception if the system runs out of memory during the DLL_THREAD_DETACH operation. This applies to regular DLLs, either statically or dynamically linked to MFC and also to any module that uses the MFC Dlls (MFC42[U].dll, MFC42[U]D.dll, MFCO42[U]D.dll, MFCN42[U]D.dll, MFCD42[U]D.dll).
MFC, in the DllMain code, during the DLL_THREAD_DETACH operation, cleans up the thread local data that it maintains. In the process, it creates some new temporary objects. If the memory allocation fails during this process due to low memory conditions in the system, it throws a memory exception. Because this exception never gets caught, you receive an unhandled exception from the process.
The Mfc42.dll and Mfc42u.dll files that shipped with Windows 2000 have this fix incorporated.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in the latest service pack for Visual Studio 6.0.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
- The Different Kinds of DLLs Available with Visual C++
- Exception Handling Topics (MFC)
- 105675 INFO: First and Second Chance Exception Handling
Additional query words: sp4 new malloc memory starved resources exit afxtermthread
Keywords: kbarchitecture kbbug kbdll kbexcepthandling kbfix kbvs600sp4fix kbvs600sp5fix KB256056