ATLASSUME(m_bInitialized) assertion failing after porting to VS2008
There was a post on social.msdn.com explaining the situation, but the page is now gone. Here’s a copy from Google’s cache.
In classes like CComObject, the critical section is no longer initialized in the constructor. It has been moved to _AtlInitialConstruct. Most of the time, this change is transparent.
To make sure the critical section has been correctly initialized, the assert was added to the Lock() method.
If this assert is hit, it means that _AtlInitialConstruct has not been called.
Scenario 1
CCom*Object has been instantiated with new and _AtlInitialConstruct is not called after the new. If CreateInstance is used to instantiate the CComObject, CreateInstance automatically calls _AtlInitialConstruct.Scenario 1 Resolution
Call
_AtlInitialConstructafter the object has been instantiated with new. or
Create aCCom*Objectinstance using the staticCreateInstancemethod.Scenario 2
A class similar to CCom*Object (not part of ATL) has been written and used in the project that hits the ASSERT.Scenario 2 Resolution
Modify
CreateInstancemethod of the custom class to call_AtlInitialConsturct. SeeCComObject::CreateInstanceimplementation for the right place to make this call.Thanks,
Sridhar Madhugiri
Software Engineer
Visual C++
- Check that you haven’t overridden InternalAddRef, and your implementation of InternalAddRef uses InterlockedIncrement(m_uRef) and not call Lock() directly
About this entry
You’re currently reading “ ATLASSUME(m_bInitialized) assertion failing after porting to VS2008 ,” an entry on Chui's Counterpoint
- Published:
- 5.19.11 / 8am
- Category:
- Engineering notes
Comments are closed
Comments are currently closed on this entry.