C++ destructor called on array index - why
Posted
by
tge
on Stack Overflow
See other posts from Stack Overflow
or by tge
Published on 2014-08-21T22:08:06Z
Indexed on
2014/08/21
22:20 UTC
Read the original article
Hit count: 214
The following code (from Apache Tuscany SDO C++) occasionally (actually very rarely) causes subsequent crashes and I don't understand what's going on. The following statement is in DataObjectImpl.cpp (see stack below):
PropertyImpl* DataObjectImpl::getPropertyImpl(unsigned int index)
{
...
904 PropertyList props = getType().getProperties();
905 if (index < props.size())
906 {
907 return (PropertyImpl*)&props[index];
...
causes the following stack (all omitted frames above and below look plausible):
Note: #11 libtuscany_sdo.dll!std::vector<>::~vector<> [c:\program files\microsoft visual studio 9.0\vc\include\vector:559]
Note: #12 libtuscany_sdo.dll!commonj::sdo::PropertyList::~PropertyList [y:\external\tuscany\src\runtime\core\src\commonj\sdo\propertylist.cpp:60]
Note: #13 libtuscany_sdo.dll!commonj::sdo::DataObjectImpl::getPropertyImpl [y:\external\tuscany\src\runtime\core\src\commonj\sdo\dataobjectimpl.cpp:907]
Note: #14 libtuscany_sdo.dll!commonj::sdo::DataObjectImpl::getSDOValue [y:\external\tuscany\src\runtime\core\src\commonj\sdo\dataobjectimpl.cpp:3845]
The actual question is - why is the destructor of PropertyList called??
As stated, the stack looks OK otherwise, also the vector destructor, as PropertyList has a member std::vector<PropertyImplPtr> plist; and the array index operator of PropertyList just calls the array index of the plist member.
And, even more puzzling (to me), why this happens only occasionally ... Many thx!!
© Stack Overflow or respective owner