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

Data race when loading fluidsynth music driver #8335

Closed
ceeac opened this issue Nov 6, 2020 · 0 comments
Closed

Data race when loading fluidsynth music driver #8335

ceeac opened this issue Nov 6, 2020 · 0 comments

Comments

@ceeac
Copy link

@ceeac ceeac commented Nov 6, 2020

Version of OpenTTD

9bd2e5b (latest master branch as of today)

Expected result

No data race

Actual result

==================
WARNING: ThreadSanitizer: data race (pid=74663)
  Write of size 8 at 0x0000025a2ec8 by main thread (mutexes: write M683):
    #0 MxSetMusicSource(void (*)(short*, unsigned long)) <null> (openttd+0x119c1c9)
    #1 MusicDriver_FluidSynth::Start(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) <null> (openttd+0xcd8ff7)
    #2 DriverFactoryBase::SelectDriverImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x1032b18)
    #3 DriverFactoryBase::SelectDriver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x10327f4)
    #4 openttd_main(int, char**) <null> (openttd+0x12cc060)
    #5 main <null> (openttd+0xd93a42)

  Previous read of size 8 at 0x0000025a2ec8 by thread T2 (mutexes: write M636):
    #0 MxMixSamples(void*, unsigned int) <null> (openttd+0x119af62)
    #1 fill_sound_buffer(void*, unsigned char*, int) <null> (openttd+0xf49856)
    #2 <null> <null> (libSDL2-2.0.so.0+0x2556e)

  Location is global '_music_stream' of size 8 at 0x0000025a2ec8 (openttd+0x0000025a2ec8)

  Mutex M683 (0x00000243d4c0) created at:
    #0 pthread_mutex_lock <null> (openttd+0xa052e6)
    #1 __gthread_mutex_lock(pthread_mutex_t*) <null> (openttd+0xc9f296)
    #2 std::mutex::lock() <null> (openttd+0xca7ca8)
    #3 std::lock_guard<std::mutex>::lock_guard(std::mutex&) <null> (openttd+0xca72d2)
    #4 MusicDriver_FluidSynth::Start(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) <null> (openttd+0xcd8eec)
    #5 DriverFactoryBase::SelectDriverImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x1032b18)
    #6 DriverFactoryBase::SelectDriver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x10327f4)
    #7 openttd_main(int, char**) <null> (openttd+0x12cc060)
    #8 main <null> (openttd+0xd93a42)

  Mutex M636 (0x7b0c00007170) created at:
    #0 pthread_mutex_init <null> (openttd+0x9e949d)
    #1 <null> <null> (libSDL2-2.0.so.0+0xee6e6)
    #2 DriverFactoryBase::SelectDriverImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x1032b18)
    #3 DriverFactoryBase::SelectDriver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x10327f4)
    #4 openttd_main(int, char**) <null> (openttd+0x12cc00b)
    #5 main <null> (openttd+0xd93a42)

  Thread T2 'SDLAudioP2' (tid=74669, running) created by main thread at:
    #0 pthread_create <null> (openttd+0x9e7f1b)
    #1 <null> <null> (libSDL2-2.0.so.0+0xee1ba)
    #2 DriverFactoryBase::SelectDriverImpl(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x1032b18)
    #3 DriverFactoryBase::SelectDriver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Driver::Type) <null> (openttd+0x10327f4)
    #4 openttd_main(int, char**) <null> (openttd+0x12cc00b)
    #5 main <null> (openttd+0xd93a42)

SUMMARY: ThreadSanitizer: data race (/media/ceeac/Projects/code/openttd/build/openttd+0x119c1c9) in MxSetMusicSource(void (*)(short*, unsigned long))
==================

Steps to reproduce

Compile with Clang + ThreadSanitizer, i.e.

cmake -DCMAKE_C_COMPILER=clang-10 -DCMAKE_CXX_COMPILER=clang++-10 -DCMAKE_CXX_FLAGS="-fsanitize=thread" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread" ..

on Ubuntu 20.04, then start the game.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant