diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 9798ee13a..b8350c626 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,17 @@ +2002-12-11 Mikael Djurfeldt + + * gc.c (scm_igc): Don't call scm_i_thread_invalidate_freelists. + + * gc.c (scm_gc_sweep): Call it here instead, which is a more + logical place. + + * threads.c (create_thread): Remember root object until the handle + of the new thread is on all_threads list. + + * root.c (scm_make_root): Moved copying of fluids until after + creation of root handle so that the fluids are GC protected. Also + removed the critical section. + 2002-12-10 Mikael Djurfeldt * gc-malloc.c, gc.h (scm_gc_malloc_prehistory): New function. diff --git a/libguile/gc.c b/libguile/gc.c index 299dfe4bd..475652018 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -570,8 +570,6 @@ scm_igc (const char *what) ++scm_gc_heap_lock; - scm_i_thread_invalidate_freelists (); - /* Let's finish the sweep. The conservative GC might point into the garbage, and marking that would create a mess. @@ -1024,6 +1022,9 @@ scm_gc_sweep (void) be GC-protected instead. */ *SCM_FREELIST_LOC (scm_i_freelist) = SCM_EOL; *SCM_FREELIST_LOC (scm_i_freelist2) = SCM_EOL; + + /* Invalidate the freelists of other threads. */ + scm_i_thread_invalidate_freelists (); } #undef FUNC_NAME diff --git a/libguile/root.c b/libguile/root.c index ff8be7094..e15a6ca61 100644 --- a/libguile/root.c +++ b/libguile/root.c @@ -105,7 +105,6 @@ scm_make_root (SCM parent) if (SCM_ROOTP (parent)) { memcpy (root_state, SCM_ROOT_STATE (parent), sizeof (scm_root_state)); - scm_copy_fluids (root_state); root_state->parent = parent; } else @@ -132,10 +131,13 @@ scm_make_root (SCM parent) root_state->block_asyncs = 0; root_state->pending_asyncs = 1; - SCM_REDEFER_INTS; SCM_NEWSMOB (root, scm_tc16_root, root_state); root_state->handle = root; - SCM_REALLOW_INTS; + + if (SCM_ROOTP (parent)) + /* Must be done here so that fluids are GC protected */ + scm_copy_fluids (root_state); + return root; } diff --git a/libguile/threads.c b/libguile/threads.c index 0c68221d7..33f092768 100644 --- a/libguile/threads.c +++ b/libguile/threads.c @@ -411,6 +411,9 @@ create_thread (scm_t_catch_body body, void *body_data, all_threads = new_threads; thread_count++; scm_i_plugin_mutex_unlock (&thread_admin_mutex); + + scm_remember_upto_here_1 (root); + scm_i_enter_guile (parent); }