Re: [Jack-Devel] Jack shutdown action

PrevNext  Index
DateSun, 18 Mar 2012 12:34:44 +0000
From Fons Adriaensen <[hidden] at linuxaudio dot org>
ToPaul Davis <[hidden] at linuxaudiosystems dot com>
CcJack Developers <[hidden] at lists dot jackaudio dot org>
In-Reply-ToPaul Davis Re: [Jack-Devel] Jack shutdown action
On Sat, Mar 17, 2012 at 07:08:55PM -0400, Paul Davis wrote:
> On Sat, Mar 17, 2012 at 5:32 PM, Fons Adriaensen <[hidden]> wrote:
> > On Sat, Mar 17, 2012 at 05:15:16PM -0400, Paul Davis wrote:
> >
> >> all other exits from within libjack are via pthread_exit() which
> >> should not take down a process. running inside gdb() with a breakpoint
> >> at _exit and then a backtrace may prove revealing.
> >
> > Indeed:
> >
> > jack_client_thread zombified - exiting from JACK
> >
> > Program received signal SIGPIPE, Broken pipe.
> 
> SIGPIPE is delivered to a process when it tries to do I/O on a
> socket/FIFO that has been closed.
> 
> the code path here is:
> 
> -------------------------------------------------------------------------------------------------
> static void
> jack_client_thread_suicide (jack_client_t* client, const char* reason)
> {
> #ifdef JACK_USE_MACH_THREADS
>         client->rt_thread_ok = FALSE;
> #endif
> 
> 	if (client->on_info_shutdown) {
> 		jack_error ("%s - calling shutdown handler", reason);
> 		client->on_info_shutdown (JackClientZombie, reason,
> client->on_info_shutdown_arg);
> 	} else if (client->on_shutdown) {
> 		jack_error ("%s - calling shutdown handler", reason);
> 		client->on_shutdown (client->on_shutdown_arg);
> 	} else {
> 		jack_error ("jack_client_thread: %s - exiting from JACK", reason);
> 		jack_client_close_aux (client);
> 		/* Need a fix : possibly make client crash if
> 		 * zombified without shutdown handler
> 		 */
> 	}
> 
> 	pthread_exit (0);
> 	/*NOTREACHED*/
> }
> 
> ---------------------------------------------------------------------------------------
> 
> note the call to pthread_exit(). this does not cause an exit from the
> process, just the end of this thread.
> 
> i don't recall any specific changes to this area. the SIGPIPE has been
> received since time began - its not something sent by the server or
> some other part of JACK.

Clearly the SIGPIPE is generated by libjack: in oop_client_deliver_request()
when it tries to deliver the 'deactivate' request. The write() there never
returns. Apparently the fd is already closed at that point. But I haven't
been able to find out why. It is closed in jack_client_close_aux(), but
only after that same function tries to deliver the 'deactivate' request,
so that can't be the problem.

If the SIGPIPE would have been there 'since time began' then almost all of
my apps should have terminated receiving it before I gave them a shutdown
callback. The didn't, which is why I gave them a shutdown callback in the
first place. Also the "Need a fix" comment in the code you quoted wouldn't
make sense - when that was written clients without a shutdown callback did
not terminate.

So either previously that SIGPIPE was not generated, or the default SIGPIPE
action has changed from 'Ignore' to 'Terminate'. I've found no evidence for
the latter.

Will keep on searching...


-- 
FA

Vor uns liegt ein weites Tal, die Sonne scheint - ein Glitzerstrahl.
PrevNext  Index

1332074093.19760_0.ltw:2,a <20120318123444.GA32208 at linuxaudio dot org>