From: "Julian Graham" <joolean@gmail.com>
To: "Neil Jerram" <neil@ossau.uklinux.net>
Cc: "Ludovic Courtès" <ludo@gnu.org>, guile-devel@gnu.org
Subject: Re: srfi-18 requirements
Date: Sun, 27 Jan 2008 21:06:13 -0500 [thread overview]
Message-ID: <2bc5f8210801271806o478f2e24u1bbc77a21a270d5a@mail.gmail.com> (raw)
In-Reply-To: <2bc5f8210801241738j25c594wfc347b337aa7ed47@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
On Jan 24, 2008 8:38 PM, Julian Graham <joolean@gmail.com> wrote:
> > - we apply the generic / bug fix patch that you already posted, except
> > without the extra thread_admin_mutex locking (which I think we
> > concluded we can't justify) - that will be to HEAD
>
> Agreed, though see below...
Actually, in light of Neil's apt suggestion that we get this thing
back on track, I resolve to stop fussing about deadlocks for the time
being -- find attached the patch described above (1 deadlock -- the
jmpbuf critical section one -- and the thread-specific mutex). Let me
know if I've missed anything.
Regards,
Julian
[-- Attachment #2: srfi-18-bugs.HEAD.patch.20080127 --]
[-- Type: application/octet-stream, Size: 6450 bytes --]
Index: libguile/ChangeLog
===================================================================
RCS file: /sources/guile/guile/guile-core/libguile/ChangeLog,v
retrieving revision 1.2421
diff -a -u -r1.2421 ChangeLog
--- libguile/ChangeLog 29 Dec 2007 01:35:33 -0000 1.2421
+++ libguile/ChangeLog 28 Jan 2008 01:54:49 -0000
@@ -1,3 +1,13 @@
+2008-01-27 Julian Graham <joolean@gmail.com>
+
+ * threads.c (do_thread_exit, scm_cancel_thread,
+ scm_set_thread_cleanup_x, scm_thread_cleanup): Lock on thread-specific
+ admin mutex instead of `thread_admin_mutex'.
+ * threads.h (scm_i_thread)[admin_mutex]: New field.
+ * throw.c (make_jmpbuf): Don't enter critical section during thread
+ spawn -- there is a possibility of deadlock if other threads are
+ exiting.
+
2007-12-29 Neil Jerram <neil@ossau.uklinux.net>
* gc.c (mark_gc_async): Change "func_data" to "fn_data", to avoid
Index: libguile/threads.c
===================================================================
RCS file: /sources/guile/guile/guile-core/libguile/threads.c,v
retrieving revision 1.90
diff -a -u -r1.90 threads.c
--- libguile/threads.c 20 Oct 2007 11:09:58 -0000 1.90
+++ libguile/threads.c 28 Jan 2008 01:54:51 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -435,6 +435,7 @@
/* XXX - check for errors. */
pipe (t->sleep_pipe);
scm_i_pthread_mutex_init (&t->heap_mutex, NULL);
+ scm_i_pthread_mutex_init (&t->admin_mutex, NULL);
t->clear_freelists_p = 0;
t->gc_running_p = 0;
t->canceled = 0;
@@ -494,7 +495,7 @@
scm_handle_by_message_noexit, NULL);
}
- scm_i_scm_pthread_mutex_lock (&thread_admin_mutex);
+ scm_i_scm_pthread_mutex_lock (&t->admin_mutex);
t->exited = 1;
close (t->sleep_pipe[0]);
@@ -502,7 +503,7 @@
while (scm_is_true (unblock_from_queue (t->join_queue)))
;
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
return NULL;
}
@@ -931,15 +932,15 @@
SCM_VALIDATE_THREAD (1, thread);
t = SCM_I_THREAD_DATA (thread);
- scm_i_scm_pthread_mutex_lock (&thread_admin_mutex);
+ scm_i_scm_pthread_mutex_lock (&t->admin_mutex);
if (!t->canceled)
{
t->canceled = 1;
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
scm_i_pthread_cancel (t->pthread);
}
else
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
return SCM_UNSPECIFIED;
}
@@ -957,13 +958,13 @@
if (!scm_is_false (proc))
SCM_VALIDATE_THUNK (2, proc);
- scm_i_pthread_mutex_lock (&thread_admin_mutex);
-
t = SCM_I_THREAD_DATA (thread);
+ scm_i_pthread_mutex_lock (&t->admin_mutex);
+
if (!(t->exited || t->canceled))
t->cleanup_handler = proc;
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
return SCM_UNSPECIFIED;
}
@@ -979,10 +980,10 @@
SCM_VALIDATE_THREAD (1, thread);
- scm_i_pthread_mutex_lock (&thread_admin_mutex);
t = SCM_I_THREAD_DATA (thread);
+ scm_i_pthread_mutex_lock (&t->admin_mutex);
ret = (t->exited || t->canceled) ? SCM_BOOL_F : t->cleanup_handler;
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
return ret;
}
@@ -1001,24 +1002,24 @@
if (scm_is_eq (scm_current_thread (), thread))
SCM_MISC_ERROR ("cannot join the current thread", SCM_EOL);
- scm_i_scm_pthread_mutex_lock (&thread_admin_mutex);
-
t = SCM_I_THREAD_DATA (thread);
+ scm_i_scm_pthread_mutex_lock (&t->admin_mutex);
+
if (!t->exited)
{
while (1)
{
- block_self (t->join_queue, thread, &thread_admin_mutex, NULL);
+ block_self (t->join_queue, thread, &t->admin_mutex, NULL);
if (t->exited)
break;
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
SCM_TICK;
- scm_i_scm_pthread_mutex_lock (&thread_admin_mutex);
+ scm_i_scm_pthread_mutex_lock (&t->admin_mutex);
}
}
res = t->result;
- scm_i_pthread_mutex_unlock (&thread_admin_mutex);
+ scm_i_pthread_mutex_unlock (&t->admin_mutex);
return res;
}
Index: libguile/threads.h
===================================================================
RCS file: /sources/guile/guile/guile-core/libguile/threads.h,v
retrieving revision 1.49
diff -a -u -r1.49 threads.h
--- libguile/threads.h 20 Oct 2007 11:09:58 -0000 1.49
+++ libguile/threads.h 28 Jan 2008 01:54:51 -0000
@@ -3,7 +3,7 @@
#ifndef SCM_THREADS_H
#define SCM_THREADS_H
-/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -52,6 +52,9 @@
SCM cleanup_handler;
SCM join_queue;
+
+ scm_i_pthread_mutex_t admin_mutex;
+
SCM result;
int canceled;
int exited;
Index: libguile/throw.c
===================================================================
RCS file: /sources/guile/guile/guile-core/libguile/throw.c,v
retrieving revision 1.114
diff -a -u -r1.114 throw.c
--- libguile/throw.c 22 Jan 2007 15:14:40 -0000 1.114
+++ libguile/throw.c 28 Jan 2008 01:54:52 -0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001, 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -75,12 +75,8 @@
make_jmpbuf (void)
{
SCM answer;
- SCM_CRITICAL_SECTION_START;
- {
- SCM_NEWSMOB2 (answer, tc16_jmpbuffer, 0, 0);
- SETJBJMPBUF(answer, (jmp_buf *)0);
- DEACTIVATEJB(answer);
- }
- SCM_CRITICAL_SECTION_END;
+ SCM_NEWSMOB2 (answer, tc16_jmpbuffer, 0, 0);
+ SETJBJMPBUF(answer, (jmp_buf *)0);
+ DEACTIVATEJB(answer);
return answer;
}
next prev parent reply other threads:[~2008-01-28 2:06 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-11 1:54 srfi-18 requirements Julian Graham
2007-10-12 8:42 ` Ludovic Courtès
2007-10-12 15:31 ` Julian Graham
2007-10-15 22:26 ` Julian Graham
2007-10-15 22:35 ` Stephen Compall
2007-10-15 22:47 ` Julian Graham
2007-10-29 14:37 ` Julian Graham
2007-11-26 18:11 ` Julian Graham
2007-11-27 9:14 ` Ludovic Courtès
2007-11-28 18:23 ` Ludovic Courtès
2007-11-28 18:55 ` Julian Graham
2007-12-01 5:08 ` Julian Graham
2007-12-01 10:21 ` Ludovic Courtès
2007-12-02 3:59 ` Julian Graham
2007-12-04 22:20 ` Neil Jerram
2007-12-04 22:29 ` Neil Jerram
2007-12-11 4:20 ` Julian Graham
2007-12-18 4:30 ` Julian Graham
2007-12-28 18:46 ` Ludovic Courtès
2007-12-28 19:08 ` Julian Graham
2007-12-28 22:35 ` Neil Jerram
2007-12-30 11:04 ` Neil Jerram
2007-12-30 20:38 ` Julian Graham
2008-01-01 19:09 ` Neil Jerram
2008-01-04 5:01 ` Julian Graham
2008-01-05 0:30 ` Neil Jerram
2008-01-06 21:41 ` Julian Graham
2008-01-08 23:11 ` Neil Jerram
2008-01-11 2:39 ` Julian Graham
2008-01-17 1:48 ` Neil Jerram
2008-01-19 20:10 ` Julian Graham
2008-01-23 22:46 ` Neil Jerram
2008-01-23 23:23 ` Julian Graham
2008-01-25 1:07 ` Neil Jerram
2008-01-25 1:38 ` Julian Graham
2008-01-28 2:06 ` Julian Graham [this message]
2008-02-03 0:30 ` Neil Jerram
2008-02-05 6:27 ` Julian Graham
2008-02-07 1:23 ` Neil Jerram
2008-02-07 3:06 ` Julian Graham
2008-02-07 23:26 ` Neil Jerram
2008-02-07 23:33 ` Julian Graham
2008-02-07 23:38 ` Neil Jerram
2008-02-08 0:04 ` Julian Graham
2008-02-11 5:14 ` Julian Graham
2008-02-19 22:48 ` Neil Jerram
2008-02-20 2:10 ` Julian Graham
2008-02-22 0:33 ` Neil Jerram
2008-02-22 4:14 ` Julian Graham
2008-02-24 9:41 ` Neil Jerram
2008-02-24 18:17 ` Julian Graham
2008-02-24 23:29 ` Neil Jerram
2008-03-01 19:56 ` Julian Graham
2008-03-08 16:34 ` Neil Jerram
2008-03-11 4:02 ` Julian Graham
2008-03-22 18:55 ` Julian Graham
2008-03-23 23:57 ` Neil Jerram
2008-03-24 22:03 ` Neil Jerram
2008-03-26 15:55 ` Julian Graham
2008-04-03 0:18 ` Neil Jerram
2008-04-03 19:07 ` Julian Graham
2008-04-09 21:29 ` Neil Jerram
2008-04-14 0:43 ` Julian Graham
2008-05-14 1:23 ` Julian Graham
2008-05-14 21:13 ` Neil Jerram
2008-05-14 23:11 ` Neil Jerram
2008-05-15 5:05 ` Julian Graham
2008-05-24 11:42 ` Neil Jerram
2008-05-24 13:55 ` Neil Jerram
2008-05-25 2:07 ` Julian Graham
2008-05-31 21:41 ` Ludovic Courtès
2008-06-02 4:48 ` Julian Graham
2008-06-21 5:03 ` Julian Graham
2008-06-30 17:51 ` Ludovic Courtès
2008-01-08 23:41 ` 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=2bc5f8210801271806o478f2e24u1bbc77a21a270d5a@mail.gmail.com \
--to=joolean@gmail.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
--cc=neil@ossau.uklinux.net \
/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).