All of lore.kernel.org
 help / color / mirror / Atom feed
* [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback]
@ 2009-03-08 16:11 Nicolas.Castagne
  2009-03-09 13:18 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas.Castagne @ 2009-03-08 16:11 UTC (permalink / raw)
  To: alsa-devel

Hi folks,

I'd need the help of some alsa developpers regarding the bug report :
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426

We've made a few progress on it, but we are stuck again.

Basically, it seems that calling snd_config_update_free_global() from a
pthread causes the program to crash when the thread terminates.



Questions are:

Should config_update_free_global NOT be called from a thread ?

In other words, is the following code valid (though dumb :=)) ?
Or is there some reason for it to crash ?



**********************************
#include <pthread.h>
#include <alsa/asoundlib.h>
void * threadWork(void *arg) {
    snd_pcm_t *playback_handle;
    if (snd_pcm_open (&playback_handle, "default",
SND_PCM_STREAM_PLAYBACK, 0) < 0)
        fprintf (stderr, "error\n";
    snd_pcm_close(playback_handle);

    snd_config_update_free_global();
    return NULL;
}
int main() {
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_t threadid;
    pthread_create( &threadid, &attr, threadWork, NULL);
    return EXIT_SUCCESS;
}
**********************************


I thank you much,

Nicolas





---------------------------- Message original ----------------------------
Objet:    Crash when snd_pcm_open is called from a thread with "pulse" as 
    playback
De:       castagne@imag.fr
Date:     Mer 4 mars 2009 8:20
À:       alsa-devel@alsa-project.org
--------------------------------------------------------------------------

Hi folks,

I hope I post on the correct mail list...
I've read somewhere that I should report bugs on a list, and not only on
the Tracker. That's the aim of this message.


On all my Fedora 10 machines,
whenever
       snd_pcm_open
has been called from a pthread using "pulse" as playback
then the program crashes when the thread terminates.

Crash in __nptl_deallocate_tsd

However, AFAIK, one should be able to call snd_pcm_open from a thread.

The full bug report is there, with a very simple sample code :
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426

I think this bug relates directly to alsa.
I hope this report is useful.


Best-
Nicolas


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback]
  2009-03-08 16:11 [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback] Nicolas.Castagne
@ 2009-03-09 13:18 ` Takashi Iwai
  2009-03-09 13:38   ` Jaroslav Kysela
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2009-03-09 13:18 UTC (permalink / raw)
  To: Nicolas.Castagne; +Cc: alsa-devel

At Sun, 8 Mar 2009 16:11:45 -0000 (GMT),
Nicolas.Castagne@imag.fr wrote:
> 
> Hi folks,
> 
> I'd need the help of some alsa developpers regarding the bug report :
> https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426
> 
> We've made a few progress on it, but we are stuck again.
> 
> Basically, it seems that calling snd_config_update_free_global() from a
> pthread causes the program to crash when the thread terminates.
> 
> 
> 
> Questions are:
> 
> Should config_update_free_global NOT be called from a thread ?
> 
> In other words, is the following code valid (though dumb :=)) ?
> Or is there some reason for it to crash ?

Hm, I don't see any reason, and I cannot reproduce a crash on my machine...


Takashi

> 
> 
> 
> **********************************
> #include <pthread.h>
> #include <alsa/asoundlib.h>
> void * threadWork(void *arg) {
>     snd_pcm_t *playback_handle;
>     if (snd_pcm_open (&playback_handle, "default",
> SND_PCM_STREAM_PLAYBACK, 0) < 0)
>         fprintf (stderr, "error\n";
>     snd_pcm_close(playback_handle);
> 
>     snd_config_update_free_global();
>     return NULL;
> }
> int main() {
>     pthread_attr_t attr;
>     pthread_attr_init(&attr);
>     pthread_t threadid;
>     pthread_create( &threadid, &attr, threadWork, NULL);
>     return EXIT_SUCCESS;
> }
> **********************************
> 
> 
> I thank you much,
> 
> Nicolas
> 
> 
> 
> 
> 
> ---------------------------- Message original ----------------------------
> Objet:    Crash when snd_pcm_open is called from a thread with "pulse" as 
>     playback
> De:       castagne@imag.fr
> Date:     Mer 4 mars 2009 8:20
> À:       alsa-devel@alsa-project.org
> --------------------------------------------------------------------------
> 
> Hi folks,
> 
> I hope I post on the correct mail list...
> I've read somewhere that I should report bugs on a list, and not only on
> the Tracker. That's the aim of this message.
> 
> 
> On all my Fedora 10 machines,
> whenever
>        snd_pcm_open
> has been called from a pthread using "pulse" as playback
> then the program crashes when the thread terminates.
> 
> Crash in __nptl_deallocate_tsd
> 
> However, AFAIK, one should be able to call snd_pcm_open from a thread.
> 
> The full bug report is there, with a very simple sample code :
> https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426
> 
> I think this bug relates directly to alsa.
> I hope this report is useful.
> 
> 
> Best-
> Nicolas
> 
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback]
  2009-03-09 13:18 ` Takashi Iwai
@ 2009-03-09 13:38   ` Jaroslav Kysela
  2009-03-09 14:18     ` Nicolas.Castagne
  0 siblings, 1 reply; 6+ messages in thread
From: Jaroslav Kysela @ 2009-03-09 13:38 UTC (permalink / raw)
  To: Nicolas.Castagne; +Cc: ALSA development

On Mon, 9 Mar 2009, Takashi Iwai wrote:

> At Sun, 8 Mar 2009 16:11:45 -0000 (GMT),
> Nicolas.Castagne@imag.fr wrote:
> > 
> > Hi folks,
> > 
> > I'd need the help of some alsa developpers regarding the bug report :
> > https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426
> > 
> > We've made a few progress on it, but we are stuck again.
> > 
> > Basically, it seems that calling snd_config_update_free_global() from a
> > pthread causes the program to crash when the thread terminates.
> > 
> > 
> > 
> > Questions are:
> > 
> > Should config_update_free_global NOT be called from a thread ?
> > 
> > In other words, is the following code valid (though dumb :=)) ?
> > Or is there some reason for it to crash ?
> 
> Hm, I don't see any reason, and I cannot reproduce a crash on my machine...

I would suggest to comment out code from snd_config_update_free_global(). 
Try to comment out snd_dlobj_cache_cleanup() at first. You may compile 
alsa-lib from the tar ball on www.alsa-project.org and use 
LD_PRELOAD=alsa-lib/src/.libs/libasound.so.2.0.0 <your_program> for tests.

						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback]
  2009-03-09 13:38   ` Jaroslav Kysela
@ 2009-03-09 14:18     ` Nicolas.Castagne
  2009-03-09 14:51       ` Jaroslav Kysela
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas.Castagne @ 2009-03-09 14:18 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: ALSA development, nicolas.castagne

Hi Jaroslav, Takashi and all,

thx for you answers.


Takashi :
> Hm, I don't see any reason, and I cannot reproduce a crash on my machine...

I can reproduce it on my three Fedora10 machines, using 2 hardware.



Jaroslav
> I would suggest to comment out code from snd_config_update_free_global().
> Try to comment out snd_dlobj_cache_cleanup() at first. You may compile
> alsa-lib from the tar ball on www.alsa-project.org and use
> LD_PRELOAD=alsa-lib/src/.libs/libasound.so.2.0.0 <your_program> for tests.

Done.

* First, no more bug when commenting    snd_dlobj_cache_cleanup

* Also,  no more bug when commenting    dlclose
       in snd_dlclose
       called from snd_dlobj_cache_cleanup



The only dynamically loaded lib is  _snd_pcm_pulse_open


Seems once again that pulse is involved somewhere.


But dunno where to look at from this point :/


I upload these new inputs on the tracker.

Best-
Nicolas


> On Mon, 9 Mar 2009, Takashi Iwai wrote:
>
>> At Sun, 8 Mar 2009 16:11:45 -0000 (GMT),
>> Nicolas.Castagne@imag.fr wrote:
>> >
>> > Hi folks,
>> >
>> > I'd need the help of some alsa developpers regarding the bug report :
>> > https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426
>> >
>> > We've made a few progress on it, but we are stuck again.
>> >
>> > Basically, it seems that calling snd_config_update_free_global() from
>> a
>> > pthread causes the program to crash when the thread terminates.
>> >
>> >
>> >
>> > Questions are:
>> >
>> > Should config_update_free_global NOT be called from a thread ?
>> >
>> > In other words, is the following code valid (though dumb :=)) ?
>> > Or is there some reason for it to crash ?
>>
>> Hm, I don't see any reason, and I cannot reproduce a crash on my
>> machine...
>
> I would suggest to comment out code from snd_config_update_free_global().
> Try to comment out snd_dlobj_cache_cleanup() at first. You may compile
> alsa-lib from the tar ball on www.alsa-project.org and use
> LD_PRELOAD=alsa-lib/src/.libs/libasound.so.2.0.0 <your_program> for tests.
>
> 						Jaroslav
>
> -----
> Jaroslav Kysela <perex@perex.cz>
> Linux Kernel Sound Maintainer
> ALSA Project, Red Hat, Inc.
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback]
  2009-03-09 14:18     ` Nicolas.Castagne
@ 2009-03-09 14:51       ` Jaroslav Kysela
  2009-03-10  9:16         ` Nicolas.Castagne
  0 siblings, 1 reply; 6+ messages in thread
From: Jaroslav Kysela @ 2009-03-09 14:51 UTC (permalink / raw)
  To: Nicolas.Castagne; +Cc: ALSA development

On Mon, 9 Mar 2009 Nicolas.Castagne@imag.fr wrote:

> Hi Jaroslav, Takashi and all,
> 
> thx for you answers.
> 
> 
> Takashi :
> > Hm, I don't see any reason, and I cannot reproduce a crash on my machine...
> 
> I can reproduce it on my three Fedora10 machines, using 2 hardware.
> 
> Jaroslav
> > I would suggest to comment out code from snd_config_update_free_global().
> > Try to comment out snd_dlobj_cache_cleanup() at first. You may compile
> > alsa-lib from the tar ball on www.alsa-project.org and use
> > LD_PRELOAD=alsa-lib/src/.libs/libasound.so.2.0.0 <your_program> for tests.
> 
> Done.
> 
> * First, no more bug when commenting    snd_dlobj_cache_cleanup
> 
> * Also,  no more bug when commenting    dlclose
>        in snd_dlclose
>        called from snd_dlobj_cache_cleanup
> 
> 
> 
> The only dynamically loaded lib is  _snd_pcm_pulse_open
> 
> 
> Seems once again that pulse is involved somewhere.

Maybe. I guess it's a glibc bug which might be Fedora specific. Could you 
try glibc from different distribution (or maybe rawhide) using LD_PRELOAD 
hack if this bug can be reproduced? Just unpack glibc rpm with rpm2cpio 
and use libc.so, libdl.so and libphread.so files for LD_PRELOAD.

						Jaroslav

-----
Jaroslav Kysela <perex@perex.cz>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback]
  2009-03-09 14:51       ` Jaroslav Kysela
@ 2009-03-10  9:16         ` Nicolas.Castagne
  0 siblings, 0 replies; 6+ messages in thread
From: Nicolas.Castagne @ 2009-03-10  9:16 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: ALSA development, nicolas.castagne

Hi Jaroslav & all,

> Maybe. I guess it's a glibc bug which might be Fedora specific. Could you
> try glibc from different distribution (or maybe rawhide) using LD_PRELOAD
> hack if this bug can be reproduced? Just unpack glibc rpm with rpm2cpio
> and use libc.so, libdl.so and libphread.so files for LD_PRELOAD.

Well, these are manipulations I am not used to :(
In particular, I never installed rawhide.

But I tried the pre compiled libraries in http://download.fedora.redhat.com
then used the downloaded libc.so, libdl.so and libphread.so at run time.


-> Fedora development version glibc-2.9.90-8.1.i686.rpm
Newer than mine. Found in :
http://download.fedora.redhat.com/pub/fedora/linux/development/i386/os/Packages/


-> Fedora release version glibc-2.9-2.i686.rpm
Older than mine. Found in :
http://download.fedora.redhat.com/pub/fedora/linux/releases/10/Everything/i386/os/Packages/


The bug is still there with both these versions.


I've tried using another glibc (eg ubuntu), but I must say I have
difficulties looking into them...


Perhaps someone has Fedora Rawhide installed, and could test ?

If this is possible he sample program is alsa_main.cpp, available at :
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4426



Cheers,
Nicolas


> On Mon, 9 Mar 2009 Nicolas.Castagne@imag.fr wrote:
>
>> Hi Jaroslav, Takashi and all,
>>
>> thx for you answers.
>>
>>
>> Takashi :
>> > Hm, I don't see any reason, and I cannot reproduce a crash on my
>> machine...
>>
>> I can reproduce it on my three Fedora10 machines, using 2 hardware.
>>
>> Jaroslav
>> > I would suggest to comment out code from
>> snd_config_update_free_global().
>> > Try to comment out snd_dlobj_cache_cleanup() at first. You may compile
>> > alsa-lib from the tar ball on www.alsa-project.org and use
>> > LD_PRELOAD=alsa-lib/src/.libs/libasound.so.2.0.0 <your_program> for
>> tests.
>>
>> Done.
>>
>> * First, no more bug when commenting    snd_dlobj_cache_cleanup
>>
>> * Also,  no more bug when commenting    dlclose
>>        in snd_dlclose
>>        called from snd_dlobj_cache_cleanup
>>
>>
>>
>> The only dynamically loaded lib is  _snd_pcm_pulse_open
>>
>>
>> Seems once again that pulse is involved somewhere.
>
> Maybe. I guess it's a glibc bug which might be Fedora specific. Could you
> try glibc from different distribution (or maybe rawhide) using LD_PRELOAD
> hack if this bug can be reproduced? Just unpack glibc rpm with rpm2cpio
> and use libc.so, libdl.so and libphread.so files for LD_PRELOAD.
>
> 						Jaroslav
>
> -----
> Jaroslav Kysela <perex@perex.cz>
> Linux Kernel Sound Maintainer
> ALSA Project, Red Hat, Inc.
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-10  9:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-08 16:11 [Re: Crash when snd_pcm_open is called from a thread with "pulse" as playback] Nicolas.Castagne
2009-03-09 13:18 ` Takashi Iwai
2009-03-09 13:38   ` Jaroslav Kysela
2009-03-09 14:18     ` Nicolas.Castagne
2009-03-09 14:51       ` Jaroslav Kysela
2009-03-10  9:16         ` Nicolas.Castagne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.