unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Andy Wingo <wingo@pobox.com>
Cc: 10655@debbugs.gnu.org
Subject: bug#10655: [2.0.3+] ‘queue_after_gc_hook’ called during thread startup leads to SIGSEGV
Date: Mon, 30 Jan 2012 16:41:17 +0100	[thread overview]
Message-ID: <87ehuhxko2.fsf@gnu.org> (raw)
In-Reply-To: <87mx95w6g9.fsf@pobox.com> (Andy Wingo's message of "Mon, 30 Jan 2012 16:33:42 +0100")

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

Hi!

I’m testing this patch:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 882 bytes --]

diff --git a/libguile/gc.c b/libguile/gc.c
index 7816801..97dfcd8 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -730,14 +730,17 @@ queue_after_gc_hook (void * hook_data SCM_UNUSED,
   if (scm_debug_cells_gc_interval == 0)
 #endif
     {
-      scm_i_thread *t = SCM_I_CURRENT_THREAD;
-
-      if (scm_is_false (SCM_CDR (after_gc_async_cell)))
-        {
-          SCM_SETCDR (after_gc_async_cell, t->active_asyncs);
-          t->active_asyncs = after_gc_async_cell;
-          t->pending_asyncs = 1;
-        }
+      if (SCM_I_CURRENT_THREAD != NULL && SCM_I_CURRENT_THREAD->guile_mode)
+	{
+	  scm_i_thread *t = SCM_I_CURRENT_THREAD;
+
+	  if (scm_is_false (SCM_CDR (after_gc_async_cell)))
+	    {
+	      SCM_SETCDR (after_gc_async_cell, t->active_asyncs);
+	      t->active_asyncs = after_gc_async_cell;
+	      t->pending_asyncs = 1;
+	    }
+	}
     }
 
   return NULL;

[-- Attachment #3: Type: text/plain, Size: 386 bytes --]


Rationale:

  - With TLS, SCM_I_CURRENT_THREAD is never NULL but the whole struct,
    including ‘guile_mode’, is zero when the thread starts.

  - Without TLS, SCM_I_CURRENT_THREAD is NULL until ‘guilify_self_1’ has
    been called.

Thoughts?

(My “benchmark” has been running for some time already and the bug
hasn’t shown up again.)

Thanks,
Ludo’.

  reply	other threads:[~2012-01-30 15:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-30 15:26 bug#10655: [2.0.3+] ‘queue_after_gc_hook’ called during thread startup leads to SIGSEGV Ludovic Courtès
2012-01-30 15:33 ` Andy Wingo
2012-01-30 15:41   ` Ludovic Courtès [this message]
2012-01-30 19:42   ` Ludovic Courtès

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=87ehuhxko2.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=10655@debbugs.gnu.org \
    --cc=wingo@pobox.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).