xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* Shutdown problems in xs.c
@ 2010-05-11 22:01 Jeremy Fitzhardinge
  2010-05-11 22:02 ` [PATCH 1 of 2] xs: make sure mutexes are cleaned up and memory freed if the read thread is cancelled Jeremy Fitzhardinge
  2010-05-11 22:03 ` [PATCH 2 of 2] xs: avoid pthread_join deadlock in xs_daemon_close Jeremy Fitzhardinge
  0 siblings, 2 replies; 3+ messages in thread
From: Jeremy Fitzhardinge @ 2010-05-11 22:01 UTC (permalink / raw)
  To: Keir Fraser; +Cc: Xen-devel, Stefano Stabellini

I've been getting deadlocks in xl, particularly "xl destroy".  It turns
out the main thread is stuck in a pthread_join while holding all the
mutexes, while the xenstore reading thread is stuck in a
pthread_mutex_lock before it can get to a cancellation point and exit.

This looks like it is a very long-standing deadlock (the code in
question mostly dates back to 2005), but perhaps something has changed
that makes it more likely to happen.  I think the original intention of
the code was to hold all the mutexes while doing the cancel/join to
avoid cancelling while the reader is holding any mutexes.  This fails
when the reader loop is not holding any, but needs to take one before
getting to a cancellation point (pthread_mutex_lock is not itself a
cancellation point).

The following two patches address it by 1) making sure that the read
thread has sufficient pthread cleanup handlers to free any
allocated-but-unused memory and release the mutexes when cancelled, and
2) do the pthread cancel/join while not holding any mutexes.

Thanks,
    J

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

end of thread, other threads:[~2010-05-11 22:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-11 22:01 Shutdown problems in xs.c Jeremy Fitzhardinge
2010-05-11 22:02 ` [PATCH 1 of 2] xs: make sure mutexes are cleaned up and memory freed if the read thread is cancelled Jeremy Fitzhardinge
2010-05-11 22:03 ` [PATCH 2 of 2] xs: avoid pthread_join deadlock in xs_daemon_close Jeremy Fitzhardinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).