wingo pushed a commit to branch wip-whippet
in repository guile.

commit 0a6767b3b9bbd4b527fda1054fb30abe3ce50736
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Thu May 22 16:24:16 2025 +0200

    Fix a bug in after-gc Scheme hook
    
    * libguile/gc.c (scm_gc_event_listener_restarting_mutators): Avoid
    running hook before Guile is booted.
---
 libguile/gc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libguile/gc.c b/libguile/gc.c
index abdfffc32..48944de73 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -41,6 +41,7 @@
 #include "gsubr.h"
 #include "hashtab.h"
 #include "hooks.h"
+#include "init.h"
 #include "list.h"
 #include "modules.h"
 #include "numbers.h"
@@ -194,7 +195,8 @@ scm_gc_event_listener_restarting_mutators (void *data)
   /* If there are Scheme hooks and we have a current Guile thread,
      enqueue those to be run on the current thread.  */
   scm_thread *t = SCM_I_CURRENT_THREAD;
-  if (t && scm_is_false (SCM_CDR (after_gc_async_cell)) &&
+  if (t && scm_initialized_p &&
+      scm_is_false (SCM_CDR (after_gc_async_cell)) &&
       scm_is_false (scm_hook_empty_p (scm_after_gc_hook)))
     {
       SCM_SETCDR (after_gc_async_cell, t->pending_asyncs);

Reply via email to