diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-04-11 08:25:51 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-04-11 20:59:49 +0300 |
commit | b3af80d5f6f2f41ba57659f72d667b003a3274bd (patch) | |
tree | d69061f58827da313b3f032b28d9992ac01d2b2c /pthread_stop_world.c | |
parent | a646d031e70e5f30cf15153299914afb03992159 (diff) | |
download | bdwgc-b3af80d5f6f2f41ba57659f72d667b003a3274bd.tar.gz |
Fix context saving when GC_suspend_thread(self)
(fix of commits 59e2bcf96, 1ae3d0fbb)
This prevents setting suspended_ext before saving context in
GC_suspend_thread as well as in GC_register_my_thread (for a thread
registered from a thread destructor).
* include/private/pthread_support.h [GC_ENABLE_SUSPEND_THREAD
&& SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): Declare
function.
* pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL
&& GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Call
GC_with_callee_saves_pushed(GC_suspend_self_blocked) before LOCK
(instead of GC_do_blocking(GC_suspend_self_inner) after LOCK); remove
comment.
* pthread_support.c [GC_ENABLE_SUSPEND_THREAD
&& SIGNAL_BASED_STOP_WORLD] (GC_register_my_thread): Likewise.
* pthread_support.c (do_blocking_locked): New static function (move
most code of GC_do_blocking_inner except for locking and
GC_lookup_thread() call).
* pthread_support.c (GC_do_blocking_inner): Call do_blocking_locked().
* pthread_support.c [GC_ENABLE_SUSPEND_THREAD
&& SIGNAL_BASED_STOP_WORLD] (GC_suspend_self_blocked): New static
function.
Diffstat (limited to 'pthread_stop_world.c')
-rw-r--r-- | pthread_stop_world.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/pthread_stop_world.c b/pthread_stop_world.c index 65dd2319..9e146831 100644 --- a/pthread_stop_world.c +++ b/pthread_stop_world.c @@ -656,10 +656,8 @@ STATIC void GC_restart_handler(int sig) if (THREAD_EQUAL((pthread_t)thread, pthread_self())) { t -> suspended_ext = TRUE; + GC_with_callee_saves_pushed(GC_suspend_self_blocked, (ptr_t)t); UNLOCK(); - /* It is safe as "t" cannot become invalid here (no race with */ - /* GC_unregister_my_thread). */ - (void)GC_do_blocking(GC_suspend_self_inner, t); return; } |