Created attachment 330214 [details] Sample program that causes the segfault Description of problem: When using the pthread library along with portaudio, program seg faults on fedora 10. How reproducible: Always, on two i386 machines, with various versions of portaudio v19. Additional info: A sample program demonstrating the bug is included. This program seg faults on all my Fedora10 machines, inside __nptl_deallocate_tsd. It runs OK on all my other linux machines (eg ubuntu, debian). I've tested various versions of portaudio, eg : - the redhat portaudio package V19-devel (built Dec 10 2008) - the latest snapshot available on http://www.portaudio.com/ V19-devel (built Jan 26 2009) - an older version version I had (built 20/06/2008) All these versions of portaudio lead to the same seg faults on Fedora 10. I bet it may be due to a problem in some packages in fedora 10. This bug may relate to https://bugzilla.redhat.com/show_bug.cgi?id=477203, but I am unsure.
Created attachment 330215 [details] gdb trace
I've looked further into the bug. It turns out that the problem originates in alsa's snd_pcm_open when opening the playback device "pulse" Included a newer, very very simple sample code. Hope this helps.
Created attachment 333317 [details] Very simple sample code, with snd_pcm_open Very simple sample code, demonstrating that the bug originate in snd_pcm_open when using "pulse" playback.
Could you please open a bug with upstream and post the upstream bug number here for monitoring.
Alsa bug report : https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426
Since this may be due to pulseaudio also (sorry, but I really can't figure out if the problem originates in pulse audio or alsa), i also opened a pulseaudio ticked. Pulse audio report : http://pulseaudio.org/ticket/506
Hmm, tried on both x86-64 and i386 to reproduce this now with no luck.
Can reproduce the crash with the pulseaudio pulseaudio-0.9.14-1, Fedora 10 up to date, on 3 machines that differ in audio and processor/motherboard hardware.
After having upgraded again Fedora 10, the sample code "Very simple sample code, with snd_pcm_open" does not crash anymore. Conversely, the sample code "Sample program that causes the segfault", that uses portaudio, still crashes on my 3 Fedora10 machines.
Yet another note. I've tried again to isolate the problem. I think the problem comes from a call to snd_config_update_free_global(). I don't know whether : - the call to snd_config_update_free_global() made by portaudio is wrong - or the call to snd_config_update_free_global() made by portaudio is correct, but the problem originates in alsalib itself. I upload new sample codes TestPaQt06.tar.gz There you'll find : 1- a sample program that uses alsa that exhibits the problem. The code may be wrong since I am not used to alsa, but the problem is there. 2- a sample program that uses portaudio that exhibits the problem. To compile the latest, just use the latest portaudio snapshot. There is a "hack" for the portaudio program : in portaudio, file portaudio/src/hostapi/alsa/pa_linux_alsa.c comment the call to snd_config_update_free_global() Just comment this line to make the bug disapear. Hope it helps.
Created attachment 334129 [details] New sample program 1- a sample program that uses alsa that exhibits the problem. The code may be wrong since I am not used to alsa, but the problem is there. 2- a sample program that uses portaudio that exhibits the problem. To compile the latest, just use the latest portaudio snapshot. There is a "hack" for the portaudio program : in portaudio, file portaudio/src/hostapi/alsa/pa_linux_alsa.c comment the call to snd_config_update_free_global() Just comment this line to make the bug disapear.
*** Bug 490196 has been marked as a duplicate of this bug. ***
Copying Hans, the new portaudio maintainer (thanks for volunteering!) :-)
The problem might be that snd_dlobj_cache_cleanup() is not thread-safe?
A crash in __nptl_deallocate_tsd typically means using pthread_key_create with a destructor, but forgetting to pthread_key_delete it in library destructors and the library being dlclosed (so it is not mapped any longer).
This is fixed now. the PA libs are now marked NODELETE so this shouldn't happen anymore.