File loading race condition leads to crashes
When loading files, the
emptyObjectAdded signal is emitted when the corresponding mesh object is created which holds the mesh that will be loaded.
Now these two things can happen in parallel:
- In the loading thread, file loading (e.g. OM or OVM) occurs
PropertyVisPlugin::slotObjectUpdatedgets called and accesses the mesh while it is being loaded
With OM, this can lead to a crash while properties are loaded from the file with the following order of execution:
- Main thread:
- File load thread:
OpenMesh::PropertyCreator::create_property(), this invalidates the fprops_begin iterator
- Main thread: The Property iterator is dereferenced -> crash
I attached the output of an ASAN instrumented build that runs into this with detailed backtraces:
How should we go about solving this? Maybe just putting a mutex around mesh access from objects? This would also prevent similar issues when performing mesh processing in a worker thread.