After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781887 - Writing to an invalid PulseAusio connection crashes
Writing to an invalid PulseAusio connection crashes
Status: RESOLVED FIXED
Product: gnome-games
Classification: Core
Component: retro-gtk
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Games maintainers
Depends on:
Blocks:
 
 
Reported: 2017-04-28 09:46 UTC by Adrien Plazas
Modified: 2017-11-08 07:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pa-player: Check the pa_simple before writing (916 bytes, patch)
2017-11-08 07:22 UTC, Adrien Plazas
committed Details | Review

Description Adrien Plazas 2017-04-28 09:46:56 UTC
When trying to write sound to PulseAudio when the server is down, Games crashes.
Comment 1 Rouby Pierre-Antoine 2017-10-30 17:06:18 UTC
To reproduce the crash on my environement, I use a spesific pulseaudio
configuration (/etc/pulse/client.conf) with the following argument "autospawn = no". And I use "$ pulseaudio --kill" to kill the deamon.

The crash occurs when we try to run a game with retro-gtk while the pulseaudio server is down.
If the game is already started, the game continue without sound.
But if we try to run a new game, Games crashes and return the following message:

  Assertion 'p' failed at pulse/simple.c:273, function pa_simple_write(). Aborting.

In retro-gtk the call "pa_simple_write" comes from the function
"retro_pa_player_on_audio_output" define in "retro-gtk/retro-pa-player.c"

  pa_simple_write (self->simple, data, sizeof (gint16) * length, NULL);

There is already verification of pulsaudio data in the "retro_pa_player_on_audio_output" function

  if (self->simple == NULL || sample_rate != self->sample_rate)
     retro_pa_player_prepare_for_sample_rate (self, sample_rate);

The function "retro_pa_player_prepare_for_sample_rate" try to initialize a new simple, with:

  self->simple = pa_simple_new (NULL, NULL, PA_STREAM_PLAYBACK, NULL, "",
                                &sample_spec, NULL, NULL, NULL);

But if the server pulseaudio is down, the "pa_simple_new()" function
return "self->simple" equal NULL, and when retro-gtk call "pa_simple_write"
the programme crashes at "pa_assert(p)".
Comment 2 Adrien Plazas 2017-11-08 07:22:37 UTC
Created attachment 363189 [details] [review]
pa-player: Check the pa_simple before writing

This avoids crashes when the construction of the pa_simple failed.
Comment 3 Adrien Plazas 2017-11-08 07:24:01 UTC
Attachment 363189 [details] pushed as a4c26d7 - pa-player: Check the pa_simple before writing