]> granicus.if.org Git - gc/commit
Fix deadlock in GC_help_marker caused by use of mark_cv of parent process
authorIvan Maidanski <ivmai@mail.ru>
Tue, 22 Aug 2017 08:23:27 +0000 (11:23 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 28 Sep 2017 08:43:34 +0000 (11:43 +0300)
commit9b7ef4d25842dc6a79eaa76200511cce5a3610f5
treea30cab503d2bb21ed511e5f1c70113eba53bd3e9
parent46d2a44df2a43829b0f7595d2b9f364980e6eae2
Fix deadlock in GC_help_marker caused by use of mark_cv of parent process

The marker threads of the parent process are blocked on mark_cv at
fork.  So pthread_cond_wait() malfunction (hang) is possible in the
child process without mark_cv state cleanup (reinitialization).

* pthread_support.c [PARALLEL_MARK] (mark_cv): Move static variable
definition upper to be before GC_start_mark_threads_inner).
* win32_threads.c [GC_PTHREADS_PARAMARK] (mark_cv): Likewise.
* pthread_support.c [PARALLEL_MARK && CAN_HANDLE_FORK] (mark_cv):
Do not initialize statically; add comment.
* win32_threads.c [GC_PTHREADS_PARAMARK && CAN_HANDLE_FORK] (mark_cv):
Likewise.
* pthread_support.c [PARALLEL_MARK && CAN_HANDLE_FORK]
(GC_start_mark_threads_inner): Initialize mark_cv to
PTHREAD_COND_INITIALIZER (unless available_markers_m1 <= 0 or
GC_parallel); add comment.
* win32_threads.c [GC_PTHREADS_PARAMARK && CAN_HANDLE_FORK]
(GC_start_mark_threads_inner): Likewise.
* pthread_support.c [PARALLEL_MARK] (GC_wait_marker,
GC_notify_all_marker): Add assertion that GC_parallel is true (so
mark_cv is initialized).
* win32_threads.c [GC_PTHREADS_PARAMARK] (GC_wait_marker,
GC_notify_all_marker): Likewise.
pthread_support.c
win32_threads.c