Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread safety issues with _fio #8870

Closed
JGRennison opened this issue Mar 16, 2021 · 3 comments
Closed

Thread safety issues with _fio #8870

JGRennison opened this issue Mar 16, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@JGRennison
Copy link
Contributor

JGRennison commented Mar 16, 2021

Version of OpenTTD

Current master 9bfa719

Context

If I remember correctly, there was some discussion/issue/etc recently about crashes in fseek on Windows, which I'm now unable to find.
Running TheadSanitizer on the current master on Linux/SDL2 brought up quite a few new warnings about thread unsafe use of _fio and fseek calls in particular.
This seems potentially related, so may be of some interest.

On the surface, it appears that multiple threads are using _fio without suitable locking, so there is the potential for threads to scribble over each other whilst doing file IO.
It looks like _fio contains static read buffers, a file descriptor, etc, which looks a bit dubious from a threaded perspective.

Probably _fio should be removed entirely or made non-static, along with related free-standing functions like FioReadByte(), etc.

Might be worth considering for 1.11?

Data

==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0774b8 by thread T20 (mutexes: write M3138):
    #0 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:98 (openttd+0xe985e0)
    #1 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #2 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #3 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #4 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #5 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #6 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #7 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #8 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #9 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #10 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #11 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #12 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #13 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #14 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #15 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #16 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #17 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #18 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #19 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #20 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #21 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #22 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x55a63c0774b8 by main thread:
    #0 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:98 (openttd+0xe985e0)
    #1 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:253 (openttd+0xd5692a)
    #2 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #3 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #4 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #5 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #6 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #7 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #8 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #9 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #10 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #11 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #12 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c4b8)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race /home/jgr/openttd/trunk4/src/fileio.cpp:98 in FioSeekToFile(unsigned char, unsigned long)
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x7b200002a100 by thread T20 (mutexes: write M3138):
    #0 memcpy <null> (libtsan.so.0+0x42333)
    #1 std::char_traits<char>::copy(char*, char const*, unsigned long) /usr/include/c++/9/bits/char_traits.h:365 (openttd+0x8cf409)
    #2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long) /usr/include/c++/9/bits/basic_string.h:351 (openttd+0x8d0380)
    #3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.tcc:272 (openttd+0x8d0d8c)
    #4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:1366 (openttd+0x8d045b)
    #5 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:696 (openttd+0x96c8e2)
    #6 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:99 (openttd+0xe9860d)
    #7 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #8 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #9 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #10 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #11 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #12 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #13 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #14 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #15 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #16 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #17 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #18 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #19 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #20 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #21 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #22 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #23 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #24 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #25 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #26 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #27 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #28 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x7b200002a100 by main thread:
    #0 memcpy <null> (libtsan.so.0+0x42333)
    #1 std::char_traits<char>::copy(char*, char const*, unsigned long) /usr/include/c++/9/bits/char_traits.h:365 (openttd+0x8cf409)
    #2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned long) /usr/include/c++/9/bits/basic_string.h:351 (openttd+0x8d0380)
    #3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.tcc:272 (openttd+0x8d0d8c)
    #4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:1366 (openttd+0x8d045b)
    #5 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:696 (openttd+0x96c8e2)
    #6 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:99 (openttd+0xe9860d)
    #7 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:253 (openttd+0xd5692a)
    #8 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #9 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #10 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #11 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #12 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #13 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #14 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #15 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #16 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #17 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #18 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is heap block of size 121 at 0x7b200002a100 allocated by thread T20:
    #0 operator new(unsigned long) <null> (libtsan.so.0+0x8c012)
    #1 __gnu_cxx::new_allocator<char>::allocate(unsigned long, void const*) /usr/include/c++/9/ext/new_allocator.h:114 (openttd+0x8d19cc)
    #2 std::allocator_traits<std::allocator<char> >::allocate(std::allocator<char>&, unsigned long) /usr/include/c++/9/bits/alloc_traits.h:444 (openttd+0x8d18a1)
    #3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long) /usr/include/c++/9/bits/basic_string.tcc:153 (openttd+0x8d1523)
    #4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.tcc:265 (openttd+0x8d0d13)
    #5 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:1366 (openttd+0x8d045b)
    #6 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:696 (openttd+0x96c8e2)
    #7 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:99 (openttd+0xe9860d)
    #8 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #9 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #10 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #11 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #12 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #13 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #14 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #15 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #16 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #17 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #18 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #19 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #20 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #21 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #22 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #23 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #24 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #25 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #26 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #27 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #28 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #29 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #30 <null> <null> (libstdc++.so.6+0xd6d83)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x42333) in memcpy
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0774c8 by thread T20 (mutexes: write M3138):
    #0 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_length(unsigned long) /usr/include/c++/9/bits/basic_string.h:183 (openttd+0x8d03cf)
    #1 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long) /usr/include/c++/9/bits/basic_string.h:216 (openttd+0x8d027c)
    #2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.tcc:274 (openttd+0x8d0d9f)
    #3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:1366 (openttd+0x8d045b)
    #4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:696 (openttd+0x96c8e2)
    #5 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:99 (openttd+0xe9860d)
    #6 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #7 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #8 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #9 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #10 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #11 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #12 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #13 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #14 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #15 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #16 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #17 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #18 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #19 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #20 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #21 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #22 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #23 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #24 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #25 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #26 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #27 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x55a63c0774c8 by main thread:
    #0 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_length(unsigned long) /usr/include/c++/9/bits/basic_string.h:183 (openttd+0x8d03cf)
    #1 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long) /usr/include/c++/9/bits/basic_string.h:216 (openttd+0x8d027c)
    #2 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.tcc:274 (openttd+0x8d0d9f)
    #3 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:1366 (openttd+0x8d045b)
    #4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /usr/include/c++/9/bits/basic_string.h:696 (openttd+0x96c8e2)
    #5 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:99 (openttd+0xe9860d)
    #6 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:253 (openttd+0xd5692a)
    #7 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #8 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #9 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #10 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #11 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #12 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #13 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #14 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #15 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #16 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #17 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c4c8)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race /usr/include/c++/9/bits/basic_string.h:183 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_length(unsigned long)
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772a8 by thread T20 (mutexes: write M3138):
    #0 FioSeekTo(unsigned long, int) /home/jgr/openttd/trunk4/src/fileio.cpp:82 (openttd+0xe98497)
    #1 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:100 (openttd+0xe9861e)
    #2 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #3 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #4 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #5 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #6 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #8 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #10 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #11 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #12 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #13 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #14 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #15 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #16 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #17 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #18 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #19 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #20 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #21 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #22 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #23 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x55a63c0772a8 by main thread:
    #0 FioSeekTo(unsigned long, int) /home/jgr/openttd/trunk4/src/fileio.cpp:82 (openttd+0xe98497)
    #1 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:100 (openttd+0xe9861e)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:253 (openttd+0xd5692a)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2a8)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race /home/jgr/openttd/trunk4/src/fileio.cpp:82 in FioSeekTo(unsigned long, int)
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772a0 by thread T20 (mutexes: write M3138):
    #0 FioSeekTo(unsigned long, int) /home/jgr/openttd/trunk4/src/fileio.cpp:82 (openttd+0xe984bd)
    #1 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:100 (openttd+0xe9861e)
    #2 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #3 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #4 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #5 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #6 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #8 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #10 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #11 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #12 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #13 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #14 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #15 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #16 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #17 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #18 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #19 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #20 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #21 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #22 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #23 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x55a63c0772a0 by main thread:
    #0 FioSeekTo(unsigned long, int) /home/jgr/openttd/trunk4/src/fileio.cpp:82 (openttd+0xe984bd)
    #1 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:100 (openttd+0xe9861e)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:253 (openttd+0xd5692a)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2a0)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race /home/jgr/openttd/trunk4/src/fileio.cpp:82 in FioSeekTo(unsigned long, int)
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0774b0 by thread T20 (mutexes: write M3138):
    #0 FioSeekTo(unsigned long, int) /home/jgr/openttd/trunk4/src/fileio.cpp:83 (openttd+0xe984d0)
    #1 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:100 (openttd+0xe9861e)
    #2 FioOpenFile(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Subdirectory) /home/jgr/openttd/trunk4/src/fileio.cpp:215 (openttd+0xe98d85)
    #3 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9374 (openttd+0x1042613)
    #4 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #5 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #6 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #8 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #10 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #11 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #12 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #13 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #14 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #15 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #16 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #17 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #18 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #19 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #20 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #21 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #22 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #23 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x55a63c0774b0 by main thread:
    #0 FioSeekTo(unsigned long, int) /home/jgr/openttd/trunk4/src/fileio.cpp:83 (openttd+0xe984d0)
    #1 FioSeekToFile(unsigned char, unsigned long) /home/jgr/openttd/trunk4/src/fileio.cpp:100 (openttd+0xe9861e)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:253 (openttd+0xd5692a)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c4b0)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race /home/jgr/openttd/trunk4/src/fileio.cpp:83 in FioSeekTo(unsigned long, int)
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772b0 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous read of size 1 at 0x55a63c0772b6 by main thread:
    #0 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:117 (openttd+0xe98776)
    #1 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #2 FioReadDword() /home/jgr/openttd/trunk4/src/fileio.cpp:153 (openttd+0xe9895a)
    #3 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:259 (openttd+0xd56947)
    #4 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #5 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:444 (openttd+0x128f4d5)
    #6 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #7 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #8 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #9 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #10 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #11 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #12 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #13 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #14 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2b0)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772b8 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous read of size 1 at 0x55a63c0772bf by main thread:
    #0 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:117 (openttd+0xe98776)
    #1 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:143 (openttd+0xe988fa)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:290 (openttd+0xd56b15)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:444 (openttd+0x128f4d5)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2b8)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772c0 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous read of size 1 at 0x55a63c0772c6 by main thread:
    #0 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:117 (openttd+0xe98776)
    #1 DecodeSingleSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, long long, unsigned char, ZoomLevel, unsigned char, unsigned char) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:76 (openttd+0xd556f8)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:313 (openttd+0xd56d46)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:444 (openttd+0x128f4d5)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2c0)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772c8 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous read of size 1 at 0x55a63c0772cc by main thread:
    #0 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:117 (openttd+0xe98776)
    #1 DecodeSingleSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, long long, unsigned char, ZoomLevel, unsigned char, unsigned char) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:68 (openttd+0xd55696)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:313 (openttd+0xd56d46)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:444 (openttd+0x128f4d5)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2c8)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772d0 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous write of size 8 at 0x55a63c0772d0 by main thread:
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 FioReadDword() /home/jgr/openttd/trunk4/src/fileio.cpp:152 (openttd+0xe9894f)
    #4 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:255 (openttd+0xd5692f)
    #5 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #6 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:441 (openttd+0x128f492)
    #7 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #8 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #9 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #10 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #11 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #12 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #13 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #14 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #15 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2d0)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c0772f8 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous read of size 1 at 0x55a63c0772fa by main thread:
    #0 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:117 (openttd+0xe98776)
    #1 DecodeSingleSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, long long, unsigned char, ZoomLevel, unsigned char, unsigned char) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:81 (openttd+0xd5572a)
    #2 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:313 (openttd+0xd56d46)
    #3 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #4 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:444 (openttd+0x128f4d5)
    #5 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #6 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #7 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #8 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #9 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #10 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #11 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #12 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #13 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c2f8)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
==================
WARNING: ThreadSanitizer: data race (pid=338769)
  Write of size 8 at 0x55a63c077340 by thread T20 (mutexes: write M3138):
    #0 fread <null> (libtsan.so.0+0x415b8)
    #1 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:111 (openttd+0xe986e2)
    #2 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #3 GetGRFContainerVersion() /home/jgr/openttd/trunk4/src/newgrf.cpp:9325 (openttd+0x10423ab)
    #4 LoadNewGRFFile(GRFConfig*, unsigned int, GrfLoadingStage, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf.cpp:9382 (openttd+0x10426f1)
    #5 FillGRFDetails(GRFConfig*, bool, Subdirectory) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:377 (openttd+0x10a4aa0)
    #6 GRFFileScanner::AddFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:612 (openttd+0x10a59ab)
    #7 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1333 (openttd+0xe9da70)
    #8 ScanPath /home/jgr/openttd/trunk4/src/fileio.cpp:1330 (openttd+0xe9d9bd)
    #9 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1380 (openttd+0xe9ddcc)
    #10 FileScanner::Scan(char const*, Subdirectory, bool, bool) /home/jgr/openttd/trunk4/src/fileio.cpp:1394 (openttd+0xe9dfa3)
    #11 GRFFileScanner::DoScan() /home/jgr/openttd/trunk4/src/newgrf_config.cpp:596 (openttd+0x10a734a)
    #12 DoScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:678 (openttd+0x10a5d41)
    #13 ScanNewGRFFiles(NewGRFScanCallback*) /home/jgr/openttd/trunk4/src/newgrf_config.cpp:726 (openttd+0x10a60f3)
    #14 GameLoop() /home/jgr/openttd/trunk4/src/openttd.cpp:1469 (openttd+0x1166e02)
    #15 VideoDriver::GameLoop() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:36 (openttd+0xd7857f)
    #16 VideoDriver::GameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:43 (openttd+0xd78609)
    #17 VideoDriver::GameThreadThunk(VideoDriver*) /home/jgr/openttd/trunk4/src/video/video_driver.cpp:80 (openttd+0xd7877c)
    #18 StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}::operator()(char const*, void (*&&)(VideoDriver*), VideoDriver*&&) const /home/jgr/openttd/trunk4/src/video/../thread.h:54 (openttd+0xd79c72)
    #19 void std::__invoke_impl<void, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*>(std::__invoke_other, StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&&&)(VideoDriver*), VideoDriver*&&)#1}, char const*&&, void (*&&)(VideoDriver*), VideoDriver*&&) /usr/include/c++/9/bits/invoke.h:60 (openttd+0xd7b106)
    #20 _ZSt8__invokeIZ14StartNewThreadIPFvP11VideoDriverEJS2_EEbPSt6threadPKcOT_DpOT0_EUlS8_OS4_OS2_E_JS8_S4_S2_EENSt15__invoke_resultIS9_JDpSB_EE4typeESA_SD_ /usr/include/c++/9/bits/invoke.h:95 (openttd+0xd7af2f)
    #21 void std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::_M_invoke<0ul, 1ul, 2ul, 3ul>(std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/9/thread:244 (openttd+0xd7ad6c)
    #22 std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> >::operator()() /usr/include/c++/9/thread:251 (openttd+0xd7acba)
    #23 std::thread::_State_impl<std::thread::_Invoker<std::tuple<StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&)::{lambda(char const*, void (*&&)(VideoDriver*), VideoDriver*&&)#1}, char const*, void (*)(VideoDriver*), VideoDriver*> > >::_M_run() /usr/include/c++/9/thread:195 (openttd+0xd7ac6c)
    #24 <null> <null> (libstdc++.so.6+0xd6d83)

  Previous read of size 1 at 0x55a63c077342 by main thread:
    #0 FioReadByte() /home/jgr/openttd/trunk4/src/fileio.cpp:117 (openttd+0xe98776)
    #1 FioReadWord() /home/jgr/openttd/trunk4/src/fileio.cpp:142 (openttd+0xe988f2)
    #2 FioReadDword() /home/jgr/openttd/trunk4/src/fileio.cpp:152 (openttd+0xe9894f)
    #3 LoadSpriteV2(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:325 (openttd+0xd56db5)
    #4 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite*, unsigned char, unsigned long, SpriteType, bool) /home/jgr/openttd/trunk4/src/spriteloader/grf.cpp:333 (openttd+0xd56e72)
    #5 ReadSprite /home/jgr/openttd/trunk4/src/spritecache.cpp:444 (openttd+0x128f4d5)
    #6 GetRawSprite(unsigned int, SpriteType, void* (*)(unsigned long), SpriteEncoder*) /home/jgr/openttd/trunk4/src/spritecache.cpp:897 (openttd+0x1290fe5)
    #7 GetSprite /home/jgr/openttd/trunk4/src/video/../blitter/../spritecache.h:43 (openttd+0xd57ae1)
    #8 OpenGLBackend::DrawMouseCursor() /home/jgr/openttd/trunk4/src/video/opengl.cpp:1042 (openttd+0xd5cc7e)
    #9 VideoDriver_SDL_OpenGL::Paint() /home/jgr/openttd/trunk4/src/video/sdl2_opengl_v.cpp:176 (openttd+0xd75d8c)
    #10 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:178 (openttd+0xd79109)
    #11 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #12 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #13 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #14 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Location is global '_fio' of size 9792 at 0x55a63c0772a0 (openttd+0x00000211c340)

  Mutex M3138 (0x7b6400005f38) created at:
    #0 pthread_mutex_lock <null> (libtsan.so.0+0x5271c)
    #1 __gthread_mutex_lock /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:749 (openttd+0xb1e3df)
    #2 std::mutex::lock() /usr/include/c++/9/bits/std_mutex.h:100 (openttd+0xb1fdb0)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/include/c++/9/bits/std_mutex.h:159 (openttd+0xb23ba0)
    #4 VideoDriver::Tick() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:157 (openttd+0xd78f49)
    #5 VideoDriver_SDL_Base::LoopOnce() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:642 (openttd+0xd6dcd5)
    #6 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:660 (openttd+0xd6dd55)
    #7 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #8 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

  Thread T20 'ottd:game' (tid=338868, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x5ea99)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) <null> (libstdc++.so.6+0xd7048)
    #2 bool StartNewThread<void (*)(VideoDriver*), VideoDriver*>(std::thread*, char const*, void (*&&)(VideoDriver*), VideoDriver*&&) /home/jgr/openttd/trunk4/src/video/../thread.h:49 (openttd+0xd79d2e)
    #3 VideoDriver::StartGameThread() /home/jgr/openttd/trunk4/src/video/video_driver.cpp:86 (openttd+0xd78827)
    #4 VideoDriver_SDL_Base::MainLoop() /home/jgr/openttd/trunk4/src/video/sdl2_v.cpp:657 (openttd+0xd6dd32)
    #5 openttd_main(int, char**) /home/jgr/openttd/trunk4/src/openttd.cpp:837 (openttd+0x1163776)
    #6 main /home/jgr/openttd/trunk4/src/os/unix/unix.cpp:265 (openttd+0xc393c0)

SUMMARY: ThreadSanitizer: data race (/usr/lib/x86_64-linux-gnu/libtsan.so.0+0x415b8) in __interceptor_fread
==================
@LordAro
Copy link
Member

LordAro commented Mar 16, 2021

#8814 ?

@JGRennison
Copy link
Contributor Author

#8814 ?

Yes. that's the one. Sorry, I had a bit of trouble remembering.

@LordAro
Copy link
Member

LordAro commented May 8, 2021

_fio is dead as of #9039, so all issues involved presumed fixed :)

@LordAro LordAro closed this as completed May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants