summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-07-03 22:00:43 -0600
committerTom Tromey <tromey@redhat.com>2013-07-03 22:00:43 -0600
commit2efa60a37de1602f2c867010b1eddda92211c7ad (patch)
treea7629af6d22089ff436fcd6d9498d17eda342331
parent39d7c9d51bf0a5d545de37ee668c5cbc17b79589 (diff)
downloademacs-2efa60a37de1602f2c867010b1eddda92211c7ad.tar.gz
unlink thread later
unlink thread from global list later also remove some unnecessary destruction code
-rw-r--r--src/thread.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/thread.c b/src/thread.c
index 361968489c6..8a81a1021a6 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -645,17 +645,6 @@ run_thread (void *state)
update_processes_for_thread_death (Fcurrent_thread ());
- /* Unlink this thread from the list of all threads. */
- for (iter = &all_threads; *iter != self; iter = &(*iter)->next_thread)
- ;
- *iter = (*iter)->next_thread;
-
- self->m_last_thing_searched = Qnil;
- self->m_saved_last_thing_searched = Qnil;
- self->name = Qnil;
- self->function = Qnil;
- self->error_symbol = Qnil;
- self->error_data = Qnil;
xfree (self->m_specpdl);
self->m_specpdl = NULL;
self->m_specpdl_ptr = NULL;
@@ -664,6 +653,14 @@ run_thread (void *state)
current_thread = NULL;
sys_cond_broadcast (&self->thread_condvar);
+ /* Unlink this thread from the list of all threads. Note that we
+ have to do this very late, after broadcasting our death.
+ Otherwise the GC may decide to reap the thread_state object,
+ leading to crashes. */
+ for (iter = &all_threads; *iter != self; iter = &(*iter)->next_thread)
+ ;
+ *iter = (*iter)->next_thread;
+
release_global_lock ();
return NULL;