[Trilinos-Users] Problems with Teuchos::XMLObject memory management?

Bartlett, Roscoe A rabartl at sandia.gov
Mon Mar 3 06:19:35 MST 2008


Hello Jonas,

The class XMLObject is a handle class that does shallow copies of the XMLObjectImplen data by default.  That is why where is no specifically defined copy constructor or assignment operator, or destructor; the compiler-generated versions should do exactly the right thing since only a single Teuchos::RCP is being stored as private data.  When you use a shallow-copy handle class you have to be very careful about sharing issues and call deepCopy() when that is what you want.  I did not write this class and there is just one simple unit test for it (see teuchos/test/XML/cxx_main.cpp) but this class has seen very heavy use in the last few years and we have need seen issues like what you describe.

Have you run valgrind or purify on your program?  The final segfault that you are seeing might be a result of other code that is corrupting the data of the XMLObject[Implem] objects.  The first that you should always do when you get a segfault is to delete all of the *.o, *.a, and *.exe files and rebuild everything from scratch.  That fixes about 50% of the segfaults that I have seen in the past.

I hope some of these ideas help,

Ross

-----Original Message-----
From: trilinos-users-bounces at software.sandia.gov [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf Of Jonas Thies
Sent: Monday, March 03, 2008 2:14 AM
Cc: trilinos-users at software.sandia.gov
Subject: [Trilinos-Users] Problems with Teuchos::XMLObject memory management?

Hi all,

I'm trying to put together a fairly complicated XML structure to be used as the 'light-weight' part of an Xdmf output format. All goes well until the end of the run, when the XMLObject is being deleted, whereupon I get a coredump. It seems that there is an issue with the internal std::vector destructor.
When I put everything in one main program it works, I suspect it has to do with the way new XMLObjects are copied into the vector. I noticed that there is a method 'deepCopy', but no copy constructor, which might explain the behaviour (std::vector push_back calls the copy constructor).
Am I doing something wrong? I'm surprised it works for the XMLParameterListWriter class. Is there an example somewhere?
By the way, I'm working with Trilinos version 8.0.1

thanks for your help,
Jonas

_______________________________________________
Trilinos-Users mailing list
Trilinos-Users at software.sandia.gov
http://software.sandia.gov/mailman/listinfo/trilinos-users




More information about the Trilinos-Users mailing list