Possible data race in the Camera::setCullMask()
Changing camera's cull mask directly seems to be not threadsafe - a draw thread uses this mask in the osgUtil::SceneView::draw()
.
This thread suggests to use the update operation, but I doubt that they will help in this case.
An example of race:
WARNING: ThreadSanitizer: data race (pid=24262)
Read of size 4 at 0x7b60000030f8 by thread T1:
#0 osgUtil::SceneView::draw() <null> (libosgUtil.so.156+0xd62a2)
#1 osgViewer::Renderer::draw() <null> (libosgViewer.so.156+0xc0485)
#2 osgViewer::Renderer::operator()(osg::GraphicsContext*) <null> (libosgViewer.so.156+0xb378e)
#3 osg::GraphicsContext::runOperations() <null> (libosg.so.156+0x2465f2)
#4 osg::RunOperations::operator()(osg::GraphicsContext*) <null> (libosg.so.156+0x239082)
#5 osg::GraphicsOperation::operator()(osg::Object*) <null> (libosg.so.156+0x2394c9)
#6 osg::OperationThread::run() <null> (libosg.so.156+0x1df5fe)
#7 osg::GraphicsThread::run() <null> (libosg.so.156+0x246f99)
#8 OpenThreads::ThreadPrivateActions::StartThread(void*) <null> (libOpenThreads.so.21+0x6f5b)
Previous write of size 4 at 0x7b60000030f8 by main thread:
#0 osg::CullSettings::applyMaskAction(unsigned int) /usr/include/osg/CullSettings:124 (openmw+0x697825)
#1 osg::CullSettings::setCullMask(unsigned int) /usr/include/osg/CullSettings:205 (openmw+0x697825)
#2 MWGui::LoadingScreen::draw() /home/andrei/Downloads/openmw/apps/openmw/mwgui/loadingscreen.cpp:363 (openmw+0x697825)
#3 MWGui::LoadingScreen::setProgress(unsigned long) /home/andrei/Downloads/openmw/apps/openmw/mwgui/loadingscreen.cpp:258 (openmw+0x697c4a)
#4 MWWorld::ESMStore::load(ESM::ESMReader&, Loading::Listener*) /home/andrei/Downloads/openmw/apps/openmw/mwworld/esmstore.cpp:118 (openmw+0x9a69fa)
#5 MWWorld::EsmLoader::load(boost::filesystem::path const&, int&) /home/andrei/Downloads/openmw/apps/openmw/mwworld/esmloader.cpp:28 (openmw+0x9b1532)
#6 MWWorld::GameContentLoader::load(boost::filesystem::path const&, int&) /home/andrei/Downloads/openmw/apps/openmw/mwworld/worldimp.cpp:105 (openmw+0x8561c9)
#7 MWWorld::World::loadContentFiles(Files::Collections const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, MWWorld::ContentLoader&) /home/andrei/Downloads/openmw/apps/openmw/mwworld/worldimp.cpp:2918 (openmw+0x838d25)
#8 MWWorld::World::World(osgViewer::Viewer*, osg::ref_ptr<osg::Group>, Resource::ResourceSystem*, SceneUtil::WorkQueue*, Files::Collections const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, ToUTF8::Utf8Encoder*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/andrei/Downloads/openmw/apps/openmw/mwworld/worldimp.cpp:183 (openmw+0x84d8c1)
#9 OMW::Engine::prepareEngine(Settings::Manager&) /home/andrei/Downloads/openmw/apps/openmw/engine.cpp:554 (openmw+0xb5c35a)
#10 OMW::Engine::go() /home/andrei/Downloads/openmw/apps/openmw/engine.cpp:691 (openmw+0xb60ed2)
#11 runApplication(int, char**) /home/andrei/Downloads/openmw/apps/openmw/main.cpp:260 (openmw+0xb45d17)
#12 wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/andrei/Downloads/openmw/components/debug/debugging.cpp:137 (openmw+0xd719ed)
#13 main /home/andrei/Downloads/openmw/apps/openmw/main.cpp:272 (openmw+0x46d51c)
Location is heap block of size 904 at 0x7b6000003000 allocated by main thread:
#0 operator new(unsigned long) /tmp/portage/sys-devel/gcc-8.2.0-r6/work/gcc-8.2.0/libsanitizer/tsan/tsan_new_delete.cc:42 (libtsan.so.0+0x7481a)
#1 osg::View::View() <null> (libosg.so.156+0x11763f)
#2 osgViewer::View::View() <null> (libosgViewer.so.156+0xa3134)
#3 osgViewer::Viewer::Viewer() <null> (libosgViewer.so.156+0x8e801)
#4 OMW::Engine::go() /home/andrei/Downloads/openmw/apps/openmw/engine.cpp:674 (openmw+0xb60a1e)
#5 runApplication(int, char**) /home/andrei/Downloads/openmw/apps/openmw/main.cpp:260 (openmw+0xb45d17)
#6 wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/andrei/Downloads/openmw/components/debug/debugging.cpp:137 (openmw+0xd719ed)
#7 main /home/andrei/Downloads/openmw/apps/openmw/main.cpp:272 (openmw+0x46d51c)
Thread T1 (tid=28317, running) created by main thread at:
#0 pthread_create /tmp/portage/sys-devel/gcc-8.2.0-r6/work/gcc-8.2.0/libsanitizer/tsan/tsan_interceptors.cc:915 (libtsan.so.0+0x2bdbe)
#1 OpenThreads::Thread::start() <null> (libOpenThreads.so.21+0x637c)
#2 OpenThreads::Thread::startThread() <null> (libOpenThreads.so.21+0x6405)
#3 osgViewer::ViewerBase::startThreading() <null> (libosgViewer.so.156+0x825f2)
#4 osgViewer::ViewerBase::setUpThreading() <null> (libosgViewer.so.156+0x82eae)
#5 osgViewer::Viewer::realize() <null> (libosgViewer.so.156+0x848e1)
#6 OMW::Engine::createWindow(Settings::Manager&) /home/andrei/Downloads/openmw/apps/openmw/engine.cpp:433 (openmw+0xb5a103)
#7 OMW::Engine::prepareEngine(Settings::Manager&) /home/andrei/Downloads/openmw/apps/openmw/engine.cpp:467 (openmw+0xb5aa0f)
#8 OMW::Engine::go() /home/andrei/Downloads/openmw/apps/openmw/engine.cpp:691 (openmw+0xb60ed2)
#9 runApplication(int, char**) /home/andrei/Downloads/openmw/apps/openmw/main.cpp:260 (openmw+0xb45d17)
#10 wrapApplication(int (*)(int, char**), int, char**, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/andrei/Downloads/openmw/components/debug/debugging.cpp:137 (openmw+0xd719ed)
#11 main /home/andrei/Downloads/openmw/apps/openmw/main.cpp:272 (openmw+0x46d51c)
SUMMARY: ThreadSanitizer: data race (/usr/lib64/libosgUtil.so.156+0xd62a2) in osgUtil::SceneView::draw()
Edited by Andrei Kortunov