vtkKdTreePointLocator FindClosestPoint crashed in VTK 9 (multithread)

Hi, I recently moved from vtk 8 to vtk 9.3.0. I have a multithreading operation using vtkKdTreePointLocator->FindClosestPoint() but now it sometimes crashes in a call stack like this:


I build the locator first in the main thread, so this function should be thread safe to call(according to vtk document). Is it broken in vtk9? I checked the source code and it seems like we never have to access this->DataSet->GetMTime() in vtk 8.


It is quite odd that the aa pointer has such a high address. It’s near unsigned long long’s maximum. This casts doubt on client code. Can you share the stack trace? Often the actual cause is located in some calling code and not where the crash took place.

Edit: You provided a part of the call stack. I mean: the part of the stack with the client code (your code) closest to the crash.



It’s in the thread operation
The kdTreePointLocator is build in the main thread on creation. Crashing at line: kdTreePointLocator->FindClosestPoint(point);

Can you share the code in Run() method? Also, can you inspect and share the address of kdTreePointLocator pointer? It is quite odd that an element of Data[] member of the vtkKdTreePointLocator object points to 0xFFFFFFFFFFFFF4F. So, how do you initialize the data in vtkKdTreePointLocator?

Try to reduce the problem to a single thread and test whether the call works without crashing.

Yep, those calls work fine running a single thread. Probably some operation is not thread safe? Or not used properly?

Well, according to the docs, that operation is suppoed to be thread-safe. Maybe you could report a bug: https://gitlab.kitware.com/vtk/vtk/-/issues/ .

It ends up being a client code issue. Some non thread safe operation done on the PolyData caused this issue.

Thanks for the help anyways! Reduce the issue to single thread definitely helped to rule out some possibilities.

1 Like