[vtkusers] FW: Deep copy of vtk Object vtkModifiedBSPTree

Biddiscombe, John A. biddisco at cscs.ch
Fri Dec 4 04:22:40 EST 2015


I just realized that what I wrote a few minutes ago was wrong.

If you are calling intersect on one thread at the start, then the build cells has completed and it is inside GetCell that the crash is occurring. Inside the BSP tree we are using the same GenericCell object, and that is why you have errors. This is not thread safe.

What you need to do is create a vtkGenericCell for each thread, and modify the Intersect call to accept the generic cell as an input param so that it can use your copy on each thread and not the internal one shared between threads.
It should be fairly trivial, but there might be other internal vars that are also being shared, in which case you might need to substitute other vars.

If I have time, I'll create a patch, if you start on one, send it to me.

ta

JB




-----Original Message-----
From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of Biddiscombe, John A.
Sent: 04 December 2015 10:14
To: vtkusers at vtk.org
Subject: [vtkusers] FW: Deep copy of vtk Object vtkModifiedBSPTree

cc'ing list for future reference

> -----Original Message-----
> From: Biddiscombe, John A.
> Sent: 04 December 2015 10:13
> To: 'Normand Robert'
> Subject: RE: [vtkusers] Deep copy of vtk Object vtkModifiedBSPTree
> 
> Robert
> 
> #0  0x00007ffff500f7cf in vtkPoints::SetData(vtkDataArray*) () from
> /usr/lib/x86_64-linux-gnu/libvtkCommonCore-6.0.so.6.0
> #1  0x00007ffff5400f1a in vtkGenericCell::SetCellType(int) () from
> /usr/lib/x86_64-linux-gnu/libvtkCommonDataModel-6.0.so.6.0
> #2  0x00007ffff54ce1a5 in vtkPolyData::GetCell(long long,
> vtkGenericCell*) () from
> /usr/lib/x86_64-linux-gnu/libvtkCommonDataModel-6.0.so.6.0
> #3  0x00007ffff774539f in 
> vtkModifiedBSPTree::IntersectCellInternal(long
> long, double const*, double const*, double, double&, double*, double*,
> int&) ()
>     from /usr/lib/x86_64-linux-gnu/libvtkFiltersFlowPaths-6.0.so.6.0
> #4  0x00007ffff7749502 in vtkModifiedBSPTree::IntersectWithLine(double
> const*, double const*, double, vtkPoints*, vtkIdList*) ()
>     from /usr/lib/x86_64-linux-gnu/libvtkFiltersFlowPaths-6.0.so.6.0
> 
> 
> Intersect with line calls GetCell, which states
>   // Description:
>   // Get cell with cellId such that: 0 <= cellId < NumberOfCells.
>   // This is a thread-safe alternative to the previous GetCell()
>   // method.
>   // THIS METHOD IS THREAD SAFE IF FIRST CALLED FROM A SINGLE THREAD 
> AND
>   // THE DATASET IS NOT MODIFIED
>   virtual void GetCell(vtkIdType cellId, vtkGenericCell *cell) = 0;
> 
> and this in turn calls vtkPolyData::GetCell, which then calls
>   if ( !this->Cells )
>     {
>     this->BuildCells();
>     }
> 
> which is certainly not thread safe, so make sure you call BuildCells 
> on your input dataset before doing any intersection tests. (and you 
> might just call mydata-
> >GetCell(0,a dummy generic cell) before the threaded part to ensure 
> >that
> initialization takes place for the main code path).
> 
> Unfortunately, there are a many gotchas like this deep in the 
> internals of vtk, so I suggest you step through with a debugger and 
> look at each call to see if there's likely to be a race. I'm going 
> away for almost a  week so I won't be able to respond very quickly after this ...
> 
> JB
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list