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

On Xcode, enabling Thread Sanitizer when running testposition breaks when moving either blue or green squares #27

Open
ericoporto opened this issue Mar 9, 2024 · 0 comments
Assignees

Comments

@ericoporto
Copy link
Contributor

ericoporto commented Mar 9, 2024

In Xcode, you can enable a Thread Sanitizer by selecting it in Scheme->Edit Scheme, for the testposition running option. I created the Xcode project by using it's generator from CMake. I am using the prebuilt SDL2 framework from SDL releases.

image

I am using the CantinaBand60.wav file for testing.

testposition(2557,0x1ecc67ac0) malloc: nano zone abandoned due to inability to reserve vm space.
AddInstanceForFactory: No factory registered for id <CFUUID 0x10484e8c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
Now queueing '/Users/user/git/mojoAL-1/cmake-build-debugxcode/CantinaBand60.wav'...
==================
WARNING: ThreadSanitizer: data race (pid=2557)
  Read of size 1 at 0x00010a91005c by thread T5 (mutexes: write M0, write M1):
    #0 mix_source(ALCcontext_struct*, ALsource*, float*, int, char) <null> (libmojoal.dylib:arm64+0x3440c)
    #1 mix_context(ALCcontext_struct*, float*, int) <null> (libmojoal.dylib:arm64+0x3249c)
    #2 playback_device_callback(void*, unsigned char*, int) <null> (libmojoal.dylib:arm64+0x31f9c)
    #3 <null> <null> (SDL2:arm64+0x34128)

  Previous write of size 1 at 0x00010a91005c by main thread (mutexes: write M2):
    #0 _alSourcefv(unsigned int, int, float const*) <null> (libmojoal.dylib:arm64+0x2110c)
    #1 _alSource3f(unsigned int, int, float, float, float) <null> (libmojoal.dylib:arm64+0x214b8)
    #2 alSource3f <null> (libmojoal.dylib:arm64+0x213e0)
    #3 mainloop(SDL_Renderer*) <null> (testposition:arm64+0x1000062e4)
    #4 spatialize(SDL_Renderer*, char const*) <null> (testposition:arm64+0x100004868)
    #5 main <null> (testposition:arm64+0x100003a14)

  Location is heap block of size 15400 at 0x00010a910000 allocated by main thread:
    #0 calloc <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x55c8c)
    #1 SDL_DYNAPI_entry <null> (SDL2:arm64+0xd75e0)
    #2 _alGenSources(int, unsigned int*) <null> (libmojoal.dylib:arm64+0x1d008)
    #3 alGenSources <null> (libmojoal.dylib:arm64+0x1bd60)
    #4 spatialize(SDL_Renderer*, char const*) <null> (testposition:arm64+0x100003c98)
    #5 main <null> (testposition:arm64+0x100003a14)

  Mutex M0 (0x00010465c6c0) created at:
    #0 pthread_mutex_init <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x30e30)
    #1 SDL_DYNAPI_entry <null> (SDL2:arm64+0xe2f64)
    #2 alcCreateContext <null> (libmojoal.dylib:arm64+0x6738)
    #3 main <null> (testposition:arm64+0x1000036ac)

  Mutex M1 (0x00010465c380) created at:
    #0 pthread_mutex_init <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x30e30)
    #1 SDL_DYNAPI_entry <null> (SDL2:arm64+0xe2f64)
    #2 alcCreateContext <null> (libmojoal.dylib:arm64+0x6738)
    #3 main <null> (testposition:arm64+0x1000036ac)

  Mutex M2 (0x00010465f2c0) created at:
    #0 pthread_mutex_init <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x30e30)
    #1 SDL_DYNAPI_entry <null> (SDL2:arm64+0xe2f64)
    #2 prep_alc_device(char const*, char) <null> (libmojoal.dylib:arm64+0x5048)
    #3 alcOpenDevice <null> (libmojoal.dylib:arm64+0x4f80)
    #4 main <null> (testposition:arm64+0x1000035a0)

  Thread T5 (tid=34370, running) created by main thread at:
    #0 pthread_create <null> (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x2ffec)
    #1 <null> <null> (SDL2:arm64+0x24fe4)
    #2 alcCreateContext <null> (libmojoal.dylib:arm64+0x6738)
    #3 main <null> (testposition:arm64+0x1000036ac)

SUMMARY: ThreadSanitizer: data race (/Users/user/git/mojoAL-1/cmake-build-debugxcode/Debug/libmojoal.dylib:arm64+0x3440c) in mix_source(ALCcontext_struct*, ALsource*, float*, int, char)+0x2ac

Anyhow it reports a read of size 1 here

mojoAL/mojoal.c

Line 1939 in 1adfdf5

if (src->recalc || force_recalc) {

While there is a write of size 1 here

mojoAL/mojoal.c

Line 3734 in 1adfdf5

source_needs_recalc(src);

This appears fine.

I don't know how much of a real issue this is as the test appears to work correctly. Still decided to report just in case.

@icculus icculus self-assigned this Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants