Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Possible thread deadlock/hang in al_detach_voice() ?

This thread is locked; no one can reply to it. rss feed Print
Possible thread deadlock/hang in al_detach_voice() ?
Bluebird
Member #15,421
December 2013

Hello, this is my first post on allegro.cc. Actually, I'm not used to posting on the internet at all (usually when I run into a programming problem I just use a search engine until I find a way to fix it), so this post is probably going to be rather stilted. I apologize in advance.

While working on a heavy C++11 wrapper for Allegro 5 to use in my game engine (which is not really an engine, just a large collection of classes), I encountered a problem when using al_detach_voice(), and also al_detach_mixer(), where the ALLEGRO_MIXER is one that is attached to an ALLEGRO_VOICE.

The problem is that, every ~5 to ~20 program executions, the code will hang at a call to al_detach_voice(). GDB says the problem occurs starting from this line, in addons/audio/kcm_voice.c, at line 379. I can provide a full backtrace if needed.

#SelectExpand
1voice->driver->stop_voice(voice);

Further inspection of GDB's backtrace would seem to indicate that Allegro is using the pulseaudio driver, but I would not know if this is specific to that driver.

I have tested and found that the exact same problem can be demonstrated with al_detach_mixer() as well (according to GDB, both call into the same underlying code in addons/audio/kcm_voice.c).

The version of Allegro I am using is Allegro 5.0.10 (debug) - the latest stable, I believe. I have not tested the WIP version, mainly because I want to use the stable release, but if someone needs me to test the unstable version, I can (assuming I can convince GCC to compile it, that is).

Here is an example program which should demonstrate the problem. You may need to run the program several times; I am able to reproduce the problem more or less reliably that way. Sometimes the program will deadlock/hang at the very first call to al_detach_voice().

#SelectExpand
1 2// This program is intended to demonstrate a possible problem in 3// al_detach_voice(). 4 5#include <allegro5/allegro.h> 6#include <allegro5/allegro_audio.h> 7 8#include <iostream> 9#include <cassert> 10 11 12 13int main(int /* argc */, char** /* argv */) 14{ 15 std::cout << "Starting tests ..." << std::endl; 16 17 // Initialize Allegro Base. 18 if(!al_init()) 19 { 20 std::cout << "al_init() failed."; 21 return -1; 22 } 23 24 // Initialize Allegro Audio add-on. 25 if(!al_install_audio()) 26 { 27 std::cout << "al_install_audio() failed."; 28 return -1; 29 } 30 31 // Sanity checks. 32 assert(al_is_system_installed()); 33 assert(al_is_audio_installed()); 34 35 ALLEGRO_VOICE* pVoice = 0; 36 ALLEGRO_MIXER* pMixer = 0; 37 38 // Configuration variables. 39 const unsigned int frequency = 44100; 40 const ALLEGRO_CHANNEL_CONF channel_conf = ALLEGRO_CHANNEL_CONF_2; 41 const ALLEGRO_AUDIO_DEPTH audio_depth = ALLEGRO_AUDIO_DEPTH_FLOAT32; 42 43 // Create the voice and mixer. 44 pVoice = al_create_voice(frequency, audio_depth, channel_conf); 45 46 if(!pVoice) 47 { 48 std::cout << "al_create_voice() failed." << std::endl; 49 return -1; 50 } 51 52 assert(pVoice); 53 54 pMixer = al_create_mixer(frequency, audio_depth, channel_conf); 55 56 if(!pMixer) 57 { 58 std::cout << "al_create_mixer() failed." << std::endl; 59 return -1; 60 } 61 62 // Sanity checks. 63 assert(pMixer); 64 assert(pVoice); 65 66 // Perform one initial attach/detach before the main test loop. Sometimes the 67 // program will hang on the very first call to al_detach_voice() or 68 // al_detach_mixer(). 69 { 70 std::cout << "Test #0 ... "; 71 std::cout.flush(); 72 bool result = al_attach_mixer_to_voice(pMixer, pVoice); 73 assert(result); 74 al_detach_voice(pVoice); 75 assert(!al_get_mixer_attached(pMixer)); 76 std::cout << "\tsucceeded." << std::endl; 77 } 78 79 80 81 // Begin testing al_attach_mixer_to_voice() and al_detach_voice() multiple 82 // times ... 83 for(int i = 1; i <= 1000; ++i) 84 { 85 std::cout << "Test #" << i << " ... "; 86 std::cout.flush(); 87 88 bool result = al_attach_mixer_to_voice(pMixer, pVoice); 89 assert(result); 90 91 // Here is one of the troublesome functions. It hangs within its call stack. 92 al_detach_voice(pVoice); 93 94 // Calling this function instead of al_detach_voice() also demonstrates the 95 // same problem. 96 // al_detach_mixer(pMixer); 97 98 assert(!al_get_mixer_attached(pMixer)); 99 std::cout << "\tsucceeded." << std::endl; 100 } 101 102 103 104 // Clean up. 105 assert(pMixer); 106 assert(pVoice); 107 al_destroy_mixer(pMixer); 108 pMixer = 0; 109 al_destroy_voice(pVoice); 110 pVoice = 0; 111 112 // Shutdown Allegro Audio add-on; Allegro Base. 113 al_uninstall_audio(); 114 al_uninstall_system(); 115 116 // Sanity checks. 117 assert(!al_is_system_installed()); 118 assert(!al_is_audio_installed()); 119 std::cout << "Tests finished." << std::endl; 120 return 0; 121}

Yes, I know attaching and detaching 1000 times is generally not realistic. But any little imperfection in Allegro bugs me. :P

I hope I am not accidentally disturbing the wrong part of the forum ....

If I missed something that someone will need, please let me know.

Arthur Kalliokoski
Second in Command
February 2005
avatar

I tried putting a delay as long as 0.05 seconds before and after the al_detach_voice and it still hung on the 12'th attempt (using a script and modified program output to write attempt number on same line). I'm currently trying it at 0.5 delay, but obviously it's going to take several hours to get as far as 12 runs. If it hangs then, it's obviously not to be taken lightly. The modified cpp file and script are in the paperclip if you want to try them. I didn't know how to put in a carrage return with cout so I used printf. :-/

[EDIT]

Oops! I forgot I started playing with it in Slackware which doesn't have pulse audio, and grabbed t.cpp from the wrong 'home'. Use the t2.cpp file.

BTW, Matt, my list of attachments in control center only shows the first couple dozen attachments and I can't delete t.cpp.

Also (Matt) Firefox doesn't copy line breaks when grabbing code from the box, it winds up just being one long line. I've been working around that by opening the post in Konqueror.

They all watch too much MSNBC... they get ideas.

Peter Wang
Member #23
April 2000

You don't need to apologise for reporting a bug.

I haven't yet reproduced it on my Slackware machine (with ALSA) or Ubuntu VM (with Pulseaudio) so stack traces of the different threads would be very helpful.

Arthur Kalliokoski
Second in Command
February 2005
avatar

I managed to get this (with the original code and debugging libraries), don't know if it helps much. It hung before printing "succeeded" on test 232, so I control-C'ed it.

Test #228 ...   succeeded.
Test #229 ...   succeeded.
Test #230 ...   succeeded.
Test #231 ...   succeeded.
Test #232 ... ^C  
Program received signal SIGINT, Interrupt.
pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
162     ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: No such file or directory.
(gdb) nb
Undefined command: "nb".  Try "help".
(gdb) b
Breakpoint 1 at 0x7ffff62cad84: file ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S, line 162.
(gdb) backtrace 
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:162
#1  0x00007ffff71d38ed in _al_cond_wait (cond=0x62e510, mutex=0x62e3d0)
    at /home/prog/allegro-5.1.7/include/allegro5/platform/aintuthr.h:81
#2  0x00007ffff71dd2dc in al_wait_cond (cond=0x62e510, mutex=0x62e3d0) at /home/prog/allegro-5.1.7/src/threads.c:365
#3  0x00007ffff7bcbfc1 in pulseaudio_stop_voice (voice=0x628af0)
    at /home/prog/allegro-5.1.7/addons/audio/pulseaudio.c:359
#4  0x00007ffff7bc95a2 in al_detach_voice (voice=0x628af0) at /home/prog/allegro-5.1.7/addons/audio/kcm_voice.c:379
#5  0x000000000040115d in main () at t3.cpp:92
(gdb) 

Or did you mean a core dump?

They all watch too much MSNBC... they get ideas.

Peter Wang
Member #23
April 2000

Turns out I was testing the ALSA driver on Ubuntu :P I can reproduce it easily as well. This particular deadlock is specific to the Allegro 5.0.10 Pulseaudio driver (and also on 5.1). It's an easy mistake to make (yes, it was me) so other backends may have a similar mistake.

Bluebird
Member #15,421
December 2013

Or did you mean a core dump?

It hasn't core dumped for me at all. It just stops and does nothing until I ctrl+c it.

@Peter Wang
Okay, here is the backtrace:

(gdb) start
Temporary breakpoint 8 at 0x400f0c: file /home/yosef/source/code-blocks-projects/al_detach_voice_t2/main.cpp, line 19.
Starting program: /home/yosef/source/code-blocks-projects/al_detach_voice_t2/./al_detach_voice 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 8, main (argc=1, argv=0x7fffffffde08) at /home/yosef/source/code-blocks-projects/al_detach_voice_t2/main.cpp:19
19        double delaytime = 0.01;
(gdb) continue
Continuing.
[New Thread 0x7ffff1ca8700 (LWP 31854)]
[New Thread 0x7fffed4a6700 (LWP 31855)]
[New Thread 0x7fffecca5700 (LWP 31856)]
^C
Program received signal SIGINT, Interrupt.
pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
185     ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: No such file or directory.
(gdb) backtrace
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffff7ac7cd5 in _al_cond_wait (cond=0x62ee00, mutex=0x62f0c0) at /home/yosef/source/allegro-5.0.10/include/allegro5/platform/aintuthr.h:81
#2  0x00007ffff7ad0209 in al_wait_cond (cond=0x62ee00, mutex=0x62f0c0) at /home/yosef/source/allegro-5.0.10/src/threads.c:365
#3  0x00007ffff78582d7 in pulseaudio_stop_voice (voice=0x610e10) at /home/yosef/source/allegro-5.0.10/addons/audio/pulseaudio.c:359
#4  0x00007ffff7856092 in al_detach_voice (voice=0x610e10) at /home/yosef/source/allegro-5.0.10/addons/audio/kcm_voice.c:379
#5  0x000000000040112d in main (argc=1, argv=0x7fffffffde08) at /home/yosef/source/code-blocks-projects/al_detach_voice_t2/main.cpp:79
(gdb) thread apply all bt

Thread 4 (Thread 0x7fffecca5700 (LWP 31856)):
#0  __lll_lock_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
#1  0x00007ffff6c6015c in _L_lock_982 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff6c5ffab in __GI___pthread_mutex_lock (mutex=0x61ff18) at pthread_mutex_lock.c:64
#3  0x00007ffff7ac7c4a in _al_mutex_lock (m=0x61ff10) at /home/yosef/source/allegro-5.0.10/include/allegro5/platform/aintuthr.h:60
#4  0x00007ffff7acffdc in al_lock_mutex (mutex=0x61ff10) at /home/yosef/source/allegro-5.0.10/src/threads.c:310
#5  0x00007ffff785503f in _al_voice_update (voice=0x610e10, samples=0x7fffecca4cd4) at /home/yosef/source/allegro-5.0.10/addons/audio/kcm_voice.c:45
#6  0x00007ffff7857bfd in pulseaudio_update (self=0x6118c0, data=0x610e10) at /home/yosef/source/allegro-5.0.10/addons/audio/pulseaudio.c:174
#7  0x00007ffff7acf37f in thread_func_trampoline (inner=0x6118c0, _outer=0x6118c0) at /home/yosef/source/allegro-5.0.10/src/threads.c:80
#8  0x00007ffff7b3951d in thread_proc_trampoline (data=0x6118c0) at /home/yosef/source/allegro-5.0.10/src/unix/uxthread.c:36
#9  0x00007ffff6c5df6e in start_thread (arg=0x7fffecca5700) at pthread_create.c:311
#10 0x00007ffff72719cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 3 (Thread 0x7fffed4a6700 (LWP 31855)):
#0  0x00007ffff7264f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff5c8f041 in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#2  0x00007ffff5c8084c in pa_mainloop_poll () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#3  0x00007ffff5c80ede in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#4  0x00007ffff5c80f90 in pa_mainloop_run () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#5  0x00007ffff5c8eff3 in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#6  0x00007ffff3d31ee8 in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so
#7  0x00007ffff6c5df6e in start_thread (arg=0x7fffed4a6700) at pthread_create.c:311
#8  0x00007ffff72719cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 2 (Thread 0x7ffff1ca8700 (LWP 31854)):
#0  0x00007ffff7269de3 in select () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007ffff7b3dbd5 in _al_xwin_background_thread (self=0x6104b0, arg=0x610450) at /home/yosef/source/allegro-5.0.10/src/x/xevents.c:184
#2  0x00007ffff7b3951d in thread_proc_trampoline (data=0x6104b0) at /home/yosef/source/allegro-5.0.10/src/unix/uxthread.c:36
#3  0x00007ffff6c5df6e in start_thread (arg=0x7ffff1ca8700) at pthread_create.c:311
#4  0x00007ffff72719cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 1 (Thread 0x7ffff7fbd880 (LWP 31853)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
#1  0x00007ffff7ac7cd5 in _al_cond_wait (cond=0x62ee00, mutex=0x62f0c0) at /home/yosef/source/allegro-5.0.10/include/allegro5/platform/aintuthr.h:81
#2  0x00007ffff7ad0209 in al_wait_cond (cond=0x62ee00, mutex=0x62f0c0) at /home/yosef/source/allegro-5.0.10/src/threads.c:365
#3  0x00007ffff78582d7 in pulseaudio_stop_voice (voice=0x610e10) at /home/yosef/source/allegro-5.0.10/addons/audio/pulseaudio.c:359
#4  0x00007ffff7856092 in al_detach_voice (voice=0x610e10) at /home/yosef/source/allegro-5.0.10/addons/audio/kcm_voice.c:379
#5  0x000000000040112d in main (argc=1, argv=0x7fffffffde08) at /home/yosef/source/code-blocks-projects/al_detach_voice_t2/main.cpp:79
(gdb) 

[Edit] I should note that this backtrace is with Arthur Kalliokoski's code.

Thomas Fjellstrom
Member #476
June 2000
avatar

valgrind includes a nice thread debug tool iirc. I think its called helgrind.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Bluebird
Member #15,421
December 2013

I've never used Valgrind's helgrind tool before so I have no idea whether this is going to be helpful .... The test program hung during the execution, so I pressed ctrl+c because I didn't know what else to do, and then helgrind wrote some more stuff. Here it is:

yosef@ArkLegacy-7750G:~/source/code-blocks-projects/al_detach_voice_t2$ valgrind --tool=helgrind ./al_detach_voice
==375== Helgrind, a thread error detector
==375== Copyright (C) 2007-2012, and GNU GPL'd, by OpenWorks LLP et al.
==375== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==375== Command: ./al_detach_voice
==375== 
==375== ---Thread-Announcement------------------------------------------
==375== 
==375== Thread #1 is the program's root thread
==375== 
==375== ----------------------------------------------------------------
==375== 
==375== Thread #1: pthread_cond_destroy: destruction of unknown cond var
==375==    at 0x4C2D7F8: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x742AE09: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==375==    by 0x742AED1: xcb_wait_for_reply (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==375==    by 0x5FF64E6: _XReply (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==375==    by 0x5FEC983: XQueryExtension (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==375==    by 0x5FE0C31: XInitExtension (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==375==    by 0x6049123: XkbUseExtension (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==375==    by 0x5FE7302: XOpenDisplay (in /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0)
==375==    by 0x4F1BC63: xglx_initialize (xsystem.c:38)
==375==    by 0x4EA363E: find_system (system.c:61)
==375==    by 0x4EA3A07: al_install_system (system.c:241)
==375==    by 0x400FA3: main (main.cpp:23)
==375== 
==375== ---Thread-Announcement------------------------------------------
==375== 
==375== Thread #3 was created
==375==    at 0x57CB98E: clone (clone.S:76)
==375==    by 0x5DA3F24: do_clone.constprop.4 (createthread.c:74)
==375==    by 0x5DA564D: pthread_create@@GLIBC_2.2.5 (createthread.c:244)
==375==    by 0x4C2E870: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8D0272C: pa_thread_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D9816B: pa_threaded_mainloop_start (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65B86: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== ----------------------------------------------------------------
==375== 
==375== Lock at 0xAF94CA0 was first observed
==375==    at 0x4C2F8EA: pthread_mutex_init (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8D01D89: pa_mutex_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D980DE: pa_threaded_mainloop_new (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65AEC: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== Lock at 0xAF94E90 was first observed
==375==    at 0x4C2F8EA: pthread_mutex_init (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8D01D89: pa_mutex_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D025A5: pa_static_mutex_get (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEDFDE: pa_once_begin (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEE14A: pa_run_once (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02ECC: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x4C2EA06: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x5DA4F6D: start_thread (pthread_create.c:311)
==375==    by 0x57CB9CC: clone (clone.S:113)
==375== 
==375== Possible data race during read of size 4 at 0x8F23C28 by thread #1
==375== Locks held: 1, at address 0xAF94CA0
==375==    at 0x8CEDFC1: pa_once_begin (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEE14A: pa_run_once (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02E23: pa_thread_self (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D986FC: pa_threaded_mainloop_wait (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65BBD: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== This conflicts with a previous write of size 4 by thread #3
==375== Locks held: 1, at address 0xAF94E90
==375==    at 0x8CEE073: pa_once_end (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02ECC: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x4C2EA06: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x5DA4F6D: start_thread (pthread_create.c:311)
==375==    by 0x57CB9CC: clone (clone.S:113)
==375== 
==375== ----------------------------------------------------------------
==375== 
==375== Lock at 0xAF94CA0 was first observed
==375==    at 0x4C2F8EA: pthread_mutex_init (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8D01D89: pa_mutex_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D980DE: pa_threaded_mainloop_new (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65AEC: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== Lock at 0xAF94E90 was first observed
==375==    at 0x4C2F8EA: pthread_mutex_init (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8D01D89: pa_mutex_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D025A5: pa_static_mutex_get (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEDFDE: pa_once_begin (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEE14A: pa_run_once (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02ECC: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x4C2EA06: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x5DA4F6D: start_thread (pthread_create.c:311)
==375==    by 0x57CB9CC: clone (clone.S:113)
==375== 
==375== Possible data race during read of size 8 at 0x8F23C30 by thread #1
==375== Locks held: 1, at address 0xAF94CA0
==375==    at 0x8D02E24: pa_thread_self (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D986FC: pa_threaded_mainloop_wait (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65BBD: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== This conflicts with a previous write of size 8 by thread #3
==375== Locks held: 1, at address 0xAF94E90
==375==    at 0x8D02C70: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEE161: pa_run_once (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02ECC: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x4C2EA06: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x5DA4F6D: start_thread (pthread_create.c:311)
==375==    by 0x57CB9CC: clone (clone.S:113)
==375== 
==375== ----------------------------------------------------------------
==375== 
==375== Lock at 0xAF94CA0 was first observed
==375==    at 0x4C2F8EA: pthread_mutex_init (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8D01D89: pa_mutex_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D980DE: pa_threaded_mainloop_new (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65AEC: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== Possible data race during read of size 4 at 0xAF84CE0 by thread #1
==375== Locks held: 1, at address 0xAF94CA0
==375==    at 0x8D02D35: pa_tls_get (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02E2F: pa_thread_self (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x6D986FC: pa_threaded_mainloop_wait (in /usr/lib/x86_64-linux-gnu/libpulse.so.0.16.2)
==375==    by 0x6B65BBD: pa_simple_new (in /usr/lib/x86_64-linux-gnu/libpulse-simple.so.0.0.4)
==375==    by 0x51C3F58: pulseaudio_allocate_voice (pulseaudio.c:248)
==375==    by 0x51C1255: al_create_voice (kcm_voice.c:84)
==375==    by 0x401065: main (main.cpp:49)
==375== 
==375== Address 0xAF84CE0 is 0 bytes inside a block of size 4 alloc'd
==375==    at 0x4C2A35B: malloc (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x8CCDA46: pa_xmalloc (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02C32: pa_tls_new (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02C6F: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8CEE161: pa_run_once (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x8D02ECC: ??? (in /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so)
==375==    by 0x4C2EA06: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x5DA4F6D: start_thread (pthread_create.c:311)
==375==    by 0x57CB9CC: clone (clone.S:113)
==375== 
^C==375== ----------------------------------------------------------------
==375== 
==375== Thread #1: Exiting thread still holds 1 lock
==375==    at 0x5DA8C84: pthread_cond_wait@@GLIBC_2.3.2 (pthread_cond_wait.S:185)
==375==    by 0x4C2EBA3: ??? (in /usr/lib/valgrind/vgpreload_helgrind-amd64-linux.so)
==375==    by 0x4E9CCD4: _al_cond_wait (aintuthr.h:81)
==375==    by 0x4EA5208: al_wait_cond (threads.c:365)
==375==    by 0x51C42D6: pulseaudio_stop_voice (pulseaudio.c:359)
==375==    by 0x51C2091: al_detach_voice (kcm_voice.c:379)
==375==    by 0x401227: main (main.cpp:99)
==375== 
==375== 
==375== For counts of detected and suppressed errors, rerun with: -v
==375== Use --history-level=approx or =none to gain increased speed, at
==375== the cost of reduced accuracy of conflicting-access information
==375== ERROR SUMMARY: 9 errors from 5 contexts (suppressed: 599944 from 3460)
Killed

I have no experience with Allegro's source (unfortunately) so I would have difficulty being more helpful than this. :-/

Peter Wang
Member #23
April 2000

Fixed in 5.1. Thanks for reporting.

Go to: