unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: "Neil Jerram" <neiljerram@googlemail.com>
To: "Julian Graham" <joolean@gmail.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: deadlock in scm_join_thread(_timed)
Date: Sun, 25 May 2008 14:16:07 +0100	[thread overview]
Message-ID: <49dd78620805250616n47ae2ecfjfe4015f066199d24@mail.gmail.com> (raw)
In-Reply-To: <2bc5f8210805242233x3ac66a60r6d135abd1d8a80a5@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]

2008/5/25 Julian Graham <joolean@gmail.com>:

> Hi everyone,
>
> While I was testing and debugging some of the SRFI-18 code that Neil
> and I were working on, I noticed a deadlock that happens in
> scm_join_thread_timed.  I'm pretty sure it affects the 1.8 codebase as
> well, although it's probably more common when doing timed joins.
>
> Thread joining in Guile (1.9 or 1.8) works as follows:
>
> 1. If the target thread has exited, return.
> 2. Block on the target thread's join queue.
> 3. When woken (because of a pthread_cond_signal, a spurious pthreads
> wakeup, or, in 1.9, a timeout expiration), check the target thread's
> exit status -- if it has exited, return.
> 4. Otherwise, SCM_TICK.
> 5. Go to step 2.
>
> The deadlock can happen if the thread exits during the tick, because
> there's no check of the exit status before block_self is called again.
>  I'm pretty sure that moving step 1 into the beginning of the loop
> would fix this --  I can submit a patch against 1.8, 1.9, or both.
> Let me know what you guys would like.
>

Hi Julian,

Based on the synopsis above, I agree that moving step 1 inside the loop
should fix this.  In addition, though, I think it would be very good if we
could add a minimal test that currently reproduces the deadlock, and so will
serve to guard against future regressions here.  Do you have such a test?

No need for a patch against both 1.8 and 1.9; just one will do, and git
cherry-pick will handle the other for us (unless the fix is significantly
different in the two branches).

Regards,
       Neil



>
> Regards,
> Julian
>
>

[-- Attachment #2: Type: text/html, Size: 2166 bytes --]

  reply	other threads:[~2008-05-25 13:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-25  5:33 deadlock in scm_join_thread(_timed) Julian Graham
2008-05-25 13:16 ` Neil Jerram [this message]
2008-05-27  2:53   ` Julian Graham
2009-05-20 18:24     ` Neil Jerram
2009-05-20 20:58       ` Neil Jerram
2009-05-20 22:25         ` Ludovic Courtès
2009-05-23 22:57           ` Neil Jerram
2009-05-24 14:03             ` Ludovic Courtès
2009-05-24 21:26               ` Neil Jerram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49dd78620805250616n47ae2ecfjfe4015f066199d24@mail.gmail.com \
    --to=neiljerram@googlemail.com \
    --cc=guile-devel@gnu.org \
    --cc=joolean@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).