[AD] thread safety in audio/acodec addon

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I fixed a thread safety issue in acodec/modaudio.c and flac.c when a stream is closed while its still playing. To debug this I used valgrind --tool=helgrind. I also saw some extra errors/warnings from it that I haven't had a chance to debug.

Also a random note (probably to myself): the logic that sends a quit event and waits for the stream thread to finish is the same in all the acodec/*.c files so it can be easily abstracted out.

The test case is here: http://lauter-helden.de/a5-stream-crash.tar.gz

==988== Possible data race during write of size 4 at 0x4b29af8 by thread #4
==988==    at 0x40771AA: pulseaudio_update (pulseaudio.c:154)
==988==    by 0x40D6D6C: thread_func_trampoline (threads.c:80)
==988==    by 0x4110275: thread_proc_trampoline (uxthread.c:44)
==988==    by 0x4026F60: mythread_wrapper (hg_intercepts.c:221)
==988==    by 0x4335E98: start_thread (pthread_create.c:304)
==988==    by 0x4240CBD: clone (clone.S:130)
==988==  This conflicts with a previous write of size 4 by thread #1
==988==    at 0x4076D89: pulseaudio_stop_voice (pulseaudio.c:274)
==988==    by 0x4075385: al_detach_voice (kcm_voice.c:379)
==988==    by 0x406B9C5: _al_kcm_detach_from_parent (kcm_instance.c:116)
==988==    by 0x406BB9A: _al_kcm_destroy_sample (kcm_instance.c:205)
==988==    by 0x406FBF5: al_destroy_mixer (kcm_mixer.c:684)
==988==    by 0x4072AF4: _al_kcm_shutdown_default_mixer (kcm_sample.c:476)
==988==    by 0x406A5B8: al_uninstall_audio (audio.c:353)
==988==    by 0x8048855: main (in /home/jon/tmp/crash/Stream-Crash/test)
==988==  Address 0x4b29af8 is 8 bytes inside a block of size 28 alloc'd
==988==    at 0x40268C4: malloc (vg_replace_malloc.c:236)
==988==    by 0x40D1447: al_malloc_with_context (memory.c:44)
==988==    by 0x4076E94: pulseaudio_allocate_voice (pulseaudio.c:166)
==988==    by 0x4074A06: al_create_voice (kcm_voice.c:84)
==988==    by 0x40720EE: al_restore_default_mixer (kcm_sample.c:86)
==988==    by 0x4072274: al_reserve_samples (kcm_sample.c:212)
==988==    by 0x80487E6: main (in /home/jon/tmp/crash/Stream-Crash/test)




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/