PRB: Destructor for Class in a DLL Called Twice

PSS ID Number: Q103860
Article last modified on 12-23-1993

3.10
WINDOWS

----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Win32 Software Development Kit (SDK) for Windows NT,
   version 3.1
----------------------------------------------------------------------

SYMPTOMS
========
The application has the following properties and generates an access
violation at exit:
 - There is a C++ class in a dynamic-link library (DLL)
 - Objects of this class type use dynamic memory
 - The application was built using the SDK tools

CAUSE
=====
Under the following conditions, the destructor for the class in the
DLL will be called twice, and therefore the memory will be freed
twice, causing the access violation.

RESOLUTION
==========
This problem does not occur when using Visual C++ for Windows NT.

MORE INFORMATION
================
This problem can be easily demonstrated by adding a CString to the
DLLTrace sample program.

Additional reference words: 3.10
KBCategory:
KBSubcategory:
Copyright Microsoft Corporation 1993.