Data race in savegame loading / GlobalMap render
(No tsan log sorry)
There's a data race between savegame loading and map generation.
The save game is loaded at https://gitlab.com/OpenMW/openmw/blob/4a9abf1c1b4e5e3dfa008ac2acebdf5788473cf4/apps/openmw/engine.cpp#L698. Eventually, it gets into ESMStore::readRecord and calls either read or finally setUp()
Store<ESM::Land> the implementation is to sort() the
Just before loading save game, in
OMW::Engine::prepareEngine the UI is initialized, which includes GlobalMap. Eventually, it gets into
GlobalMap::render. This creates a
CreateMapWorkItem and pushes it on a
mWorkQueue, executed from another thread. Inside
Store<ESM::Land> is accessed via
mLandStore.search (x,y); which results in a race condition since it's being sorted by another thread.
This is likely introduced by commit 72c6b11c, I'm not sure of the purpose since it appears map render is only called once. A "cheap" way to fix the race would be https://github.com/xyzz/openmw-android/blob/043963589f3cc793d96517d6d8e3368739aaaae8/buildscripts/patches/openmw/0003-globalmap-fix-race-vs-savegame-load.patch