[xsd-users] prgram crashes on deletion xsd::cxx::tree::optional instance

Jan Klimke jan.klimke at hpi.uni-potsdam.de
Mon Mar 23 11:32:08 EDT 2009


Hi Boris,

i found a piece of code in my projekt where i try to resolve idrefs on
cloning.

gml::FeaturePropertyType::FeaturePropertyType( const
FeaturePropertyType& fp, xml_schema::Flags f/*= 0*/,
xml_schema::Container* c/*= 0*/ ):FeaturePropertyTypeBase(fp,f,c){
    if(fp.getHref().present() && !fp.get_Feature().present()){
        std::string gmlId = fp.getHref().get().substr(1,gmlId.size()-1);
        xml_schema::Idref ref(gmlId,0,this);
        //Check for existance in container
        AbstractFeatureType* feature =
static_cast<gml::AbstractFeatureType*>(ref.get());
        if(feature){
            //set a link if it allready extists
            this->setHref(fp.getHref());
        }else{
            //add the feature if it does not exist
            this->set_Feature(*fp.getFeature());
        }                                                               
               
    }
}


Tt tries to copy the _Feature element from the old object model to the
new one if they do not already exist. I implemented the method
getFeature() to resolve idrefs and return a pointer to the referenced
object or null if it does not exist. is it possible that children
pointer are not copied when i do this like this ?


Kind regards,
Jan

Boris Kolpackov schrieb:
> Hi Jan,
>
> Jan Klimke <jan.klimke at hpi.uni-potsdam.de> writes:
>
>   
>> This does not happen every time whe i call delete on a csd-generated
>> object instance.
>>
>> Do you have any hint where i could have a look at?
>>     
>
> It is quite hard to end up with the same object being owned by two
> or more object models (and thus deleted twice) in C++/Tree. So I
> would say the most likely cause is memory corruption somewhere in
> your application. Try to run it under a memory access checker, such
> as Valgrind on Linux/UNIX. Also, if you can create a test case that
> reproduces this problem under Linux, I can take a look.
>
> Boris
>   




More information about the xsd-users mailing list