[visit-developers] corrupt "links" in vtk unstructured grid?

Mark Miller miller86 at llnl.gov
Thu Oct 16 18:40:06 EDT 2008


Hi Kathleen,

Seeing this discussion of BuildLinks reminded me of a bad leak we've had
(perhaps the one Kathleen mentions below) related to BuildLinks. At the
time it was originally observed and logged, I thought there was only one
place in all of VisIt where BuildLinks was being used and I could not
for the life of me understand the cause of the leak. Seeing Jeremy's
explanation that VTK assumes the caller first checks for existance of
links before calling BuildLinks kinda explains that. 

So, I just want to caution that we take care to check leak behavior if
we adjust/change use of BuildLinks anywhere in VisIt.

On Thu, 2008-10-16 at 15:11, Kathleen Bonnell wrote:
> Hank,
> 
> When I did a search to see what filters used BuildLinks, I noticed that
> for avtUnstructuredDomainBoundaries, you removed a direct call
> to BuildLinks due to a memory leak -- should a similar change
> be made in other places we use BuildLinks?
> 
> Kathleen
> 
> On Thursday 16 October 2008 15:03, Hank Childs wrote:
> > Hi Jeremy,
> >
> > I think I would have to do a VTK search to answer this question
> > definitively.  However, I remember looking at this issue before and being
> > frustrated by how VTK did it (a bug I think).
> >
> > But I wonder if there is a punt-type solution here.  Many of the stages in
> > the generic database add an array to the input data set.  They don't make a
> > copy, they just add it.  Could you do that here?
> >
> > I think the other way to do it _might_ be that you create a new
> > connectivity object directly from arrays and then shallow copy the points,
> > the point data, the cell data, and the field data.  I'll see if I can find
> > an example of that.
> >
> > -Hank
> >
> > --- On Thu, 10/16/08, Meredith, Jeremy S. <jsmeredith at ornl.gov> wrote:
> > > From: Meredith, Jeremy S. <jsmeredith at ornl.gov>
> > > Subject: Re: [visit-developers] corrupt "links" in vtk unstructured grid?
> > > To: "VisIt Developers" <visit-developers at email.ornl.gov>
> > > Date: Thursday, October 16, 2008, 2:51 PM
> > > We don't have any control over that, do we?  E.g., the
> > > recentering
> > > filter (vtkVisItCellDataToPointData) just calls
> > > GetPointCells, and
> > > GetPointCells is the one that calls BuildLinks if Links is
> > > NULL.  We'd
> > > have to know which filters use Links even indirectly.  And
> > > ShallowCopy
> > > is the one doing the copying of the links.....
> > >
> > > So let's turn this around into the safety of my current
> > > solution:
> > >
> > > Option #1: In this case, MIR needs to simply return the
> > > input data set,
> > > but with a new array added ("avtSubsets").  So I
> > > have to add the
> > > avtSubsets to the input data set.  That seems a little
> > > weird to modify
> > > the input dataset....
> > >
> > > Option #2: But if I make a shallow or deep copy (to which I
> > > add the
> > > avtSubsets array), I have to test if it's an
> > > unstructured grid, and if
> > > so, cast vtkDataSet to vtkUnstructuredGrid and call
> > > BuildLinks to force
> > > it to rebuild them.
> > >
> > > Neither one of these seems like a particularly elegant
> > > solution.  Any
> > > advice on the Right Way to do this?
> > >
> > > (BTW, valgrind shows no errors until the point at which
> > > this gets to the
> > > recentering filter, so I don't think I'm doing
> > > anything blatantly
> > > wrong.)
> > >
> > > --
> > > Jeremy Meredith
> > > Oak Ridge National Laboratory
> > >
> > > > -----Original Message-----
> > > > From: visit-developers-bounces at email.ornl.gov
> > >
> > > [mailto:visit-developers-
> > >
> > > > bounces at email.ornl.gov] On Behalf Of Kathleen Bonnell
> > > > Sent: Thursday, October 16, 2008 5:42 PM
> > > > To: VisIt Developers
> > > > Subject: Re: [visit-developers] corrupt
> > >
> > > "links" in vtk unstructured
> > >
> > > > grid?
> > > >
> > > > Sounds like another filter modified the data before
> > >
> > > contour received
> > >
> > > > it,
> > > > but neglected to update the links ...
> > > >
> > > > begs the question ... should we be passing around the
> > >
> > > links or should
> > >
> > > > it
> > > > be the case that any filter that requires them should
> > >
> > > build them on
> > > the
> > >
> > > > fly?
> > > >
> > > > Kathleen
> > > >
> > > > On Thursday 16 October 2008 14:34, Meredith, Jeremy S.
> > >
> > > wrote:
> > > > > Excellent question -- not exactly. Let me give
> > >
> > > you the 5-second
> > >
> > > > summary:
> > > > > - I've added code to allow datasets to pass
> > >
> > > through MIR *untouched*
> > >
> > > > > - It technically returns a shallow copy of the
> > >
> > > dataset (though
> > >
> > > > returning
> > > >
> > > > > a deep copy, or even the original, doesn't
> > >
> > > appear to fix the
> > > problem)
> > >
> > > > > - I'm making a contour plot of a
> > >
> > > material-selected dataset
> > >
> > > > > - And by the time the contour filter wants to
> > >
> > > recenter the data set,
> > >
> > > > it
> > > >
> > > > > appears to have an unstructured grid with a
> > >
> > > corrupt Links
> > >
> > > > > The problem is that Links isn't empty -- if
> > >
> > > it were, then
> > >
> > > > GetPointCells
> > > >
> > > > > would create it for me -- it's actually
> > >
> > > pointing to something that's
> > >
> > > > > either been freed, or something.
> > > > >
> > > > > (Speaking of which, vtkUnstructuredGrid::Reset()
> > >
> > > looks like a good
> > >
> > > > > alternative here, but it also resets the
> > >
> > > Connectivity, which I
> > >
> > > > believe
> > > >
> > > > > is somewhat critical, right?)
> > > > >
> > > > > --
> > > > > Jeremy Meredith
> > > > > Oak Ridge National Laboratory
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Kathleen Bonnell
> > >
> > > [mailto:kbonnell at llnl.gov]
> > >
> > > > > > Sent: Thursday, October 16, 2008 5:02 PM
> > > > > > To: VisIt Developers; Meredith, Jeremy S.
> > > > > > Subject: Re: [visit-developers] corrupt
> > >
> > > "links" in vtk
> > > unstructured
> > >
> > > > > > grid?
> > > > > >
> > > > > > Jeremy,
> > > > > >
> > > > > > I believe this is needed in order to extract
> > >
> > > connectivity
> > >
> > > > information,
> > > >
> > > > > > it is used in several filters in VisIt.
> > > > > >
> > > > > > Is your use case a newly constructed grid?
> > > > > >
> > > > > > Kathleen
> > > > > >
> > > > > > On Thursday 16 October 2008 13:48, Meredith,
> > >
> > > Jeremy S. wrote:
> > > > > > > Has anyone ever come across this
> > >
> > > before?
> > >
> > > > > > > I've gotten into a situation where
> > >
> > > I need to add a call to
> > >
> > > > > > "BuildLinks"
> > > > > >
> > > > > > > before calling
> > >
> > > "GetPointCells"  (this is in the cell data to
> > >
> > > > point
> > > >
> > > > > > data
> > > > > >
> > > > > > > recentering filter).  If I don't,
> > >
> > > it appears to just be reading
> > >
> > > > > > random
> > > > > >
> > > > > > > uninitialized point ID's for this
> > >
> > > case.
> > >
> > > > > > > (I recall something similar to this,
> > >
> > > but I'm thinking it's about
> > >
> > > > > > > "InitTraversal", not
> > >
> > > BuildLinks.)
> > >
> > > > > > > --
> > > > > > >
> > > > > > > Jeremy Meredith
> > > > > > >
> > > > > > > Oak Ridge National Laboratory
-- 
Mark C. Miller, Lawrence Livermore National Laboratory
email: mailto:miller86 at llnl.gov
(M/T/W) (925)-423-5901 (!!LLNL BUSINESS ONLY!!)
(Th/F)  (530)-753-8511 (!!LLNL BUSINESS ONLY!!)



More information about the visit-developers mailing list