DOCUMENT:Q219415 12-FEB-2002 [visualc] TITLE :PRB: Incorrect Code Generated by Cluster Resource Type Wizard PRODUCT :Microsoft C Compiler PROD/VER::5.0,5.0sp1,5.0sp2,5.0sp3,6.0 OPER/SYS: KEYWORDS:kbClustServ100bug kbVC500bug kbVC600bug kbprb kbNoUpdate ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual C++, 32-bit Enterprise Edition, versions 5.0, 5.0sp1, 5.0sp2, 5.0sp3, 6.0 - Microsoft Visual C++, 32-bit Professional Edition, versions 5.0, 5.0sp1, 5.0sp2, 5.0sp3, 6.0 - Microsoft Visual C++, 32-bit Learning Edition, version 6.0 - Microsoft Cluster Server ------------------------------------------------------------------------------- SYMPTOMS ======== Code generated for the Extension .dll by the Cluster Resource Type Wizard included in the Visual C++ versions listed above may cause an access violation in Cluster Administrator if an error occurs while adding pages to a wizard. CAUSE ===== An interface pointer is copied to an object member variable, but AddRef is never called on the interface. If an error occurs in the same method call, the local interface copy is released, but the member variable's copy won't be released. When the object's destructor is called, Release is invoked on the member variable's copy, which raises an access violation. RESOLUTION ========== The following code excerpt shows the resolution for this issue: STDMETHODIMP CExtObject::CreateWizardPages( IN IUnknown * piData, IN IWCWizardCallback * piCallback ) { ... try { ... m_piWizardCallback = piCallback; ... for ( ... ) { ... if (!ppage->BInit(this)) throw &exc; ... } // for } // try ... if (hr != NOERROR) { piCallback->Release(); // The error is here. Because piCallback is saved in // m_piWizardCallback, the CExtObject destructor // tries to call the Release() method on this // interface pointer. Therefore, we need to set that // pointer to NULL. // The following if-block must be added: if (m_piWizardCallback == piCallback) { m_piWizardCallback = NULL; } piData->Release(); m_piData = NULL; } // if return hr; } STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. Additional query words: ====================================================================== Keywords : kbClustServ100bug kbVC500bug kbVC600bug kbprb kbNoUpdate Technology : kbVCsearch kbAudDeveloper kbClustServSearch kbVC500 kbVC600 kbVC32bitSearch kbVC500SP1 kbVC500SP2 kbVC500SP3 kbVC500Search Version : :5.0,5.0sp1,5.0sp2,5.0sp3,6.0 Issue type : kbbug kbprb Solution Type : kbfix ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2002.