aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-go.c
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/runtime/go-go.c')
-rw-r--r--libgo/runtime/go-go.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libgo/runtime/go-go.c b/libgo/runtime/go-go.c
index 3146268..8c2de28 100644
--- a/libgo/runtime/go-go.c
+++ b/libgo/runtime/go-go.c
@@ -94,6 +94,13 @@ remove_current_thread (void)
runtime_MCache_ReleaseAll (mcache);
+ /* As soon as we release this look, a GC could run. Since this
+ thread is no longer on the list, the GC will not find our M
+ structure, so it could get freed at any time. That means that
+ any code from here to thread exit must not assume that the m is
+ valid. */
+ m = NULL;
+
i = pthread_mutex_unlock (&__go_thread_ids_lock);
__go_assert (i == 0);