On sink unlinking, existing sink inputs are moved, which in turn calls
a get latency callback, which references the jack client. Therefore,
make sure the sink is unlinked before the client is closed. Failure to
do so might lead to SIGSEGV.

This patch simply moves the call to pa_sink_unlink above
jack_client_close, which fixes the problem.

Steps to reproduce:

1. Disable autospawn and kill PA
2. Start jack server
3. Start PA
4. Load module module-jack-sink
5. Start a stream (e g Rythmbox) and run it through the jack sink.
6. Shutdown the jack server. Now PA crashes with SIGSEGV.

@Daniel T Chen: let me know if you want this patch as a merge proposal as
well. There is no bug in Launchpad AFAIK.

>From fa2dcce3201753bff94adba99b6bc36a7eaf57f9 Mon Sep 17 00:00:00 2001
From: David Henningsson <di...@ubuntu.com>
Date: Sun, 14 Mar 2010 20:20:12 +0100
Subject: [PATCH] Fix crash on jack server shutdown

On sink unlinking, existing sink inputs are moved, which in turn calls
a get latency callback, which references the jack client. Therefore,
make sure the sink is unlinked before the client is closed. Failure to
do so might lead to SIGSEGV.

---
 src/modules/jack/module-jack-sink.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index 9f3e071..e4467d3 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -475,12 +475,12 @@ void pa__done(pa_module*m) {
     if (!(u = m->userdata))
         return;
 
-    if (u->client)
-        jack_client_close(u->client);
-
     if (u->sink)
         pa_sink_unlink(u->sink);
 
+    if (u->client)
+        jack_client_close(u->client);
+
     if (u->thread) {
         pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
         pa_thread_free(u->thread);
-- 
1.7.0
_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to