-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gctest hang if compiled with TSan (Linux) #181
Comments
Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Use sched_yield() instead of sigsuspend(&suspend_handler_mask); add TODO item.
Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Call pthread_sigmask(SIG_SETMASK) with an empty set (thus unmask all signals); add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_stop_world): Call sem_trywait() repeatedly (with a delay of 100 microseconds) while getting EAGAIN error (instead of a sem_wait call).
Build link: https://travis-ci.org/ivmai/bdwgc/jobs/310827153 |
(fix commit af409e4) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_retry_signals): Initialize to TRUE. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_store_stack_ptr): Update comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (GC_suspend_thread): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_stop_world): Do not use sem_trywait+sleep workaround (not needed if GC_retry_signals).
gctest hang still occurs sometimes:
|
Fixed. |
(fix commit af409e4) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Call pthread_sigmask() after last_stop_count update (thus preventing duplicate sem_post() call in case of GC_suspend_handler_inner is re-entered (if GC_retry_signals); refine comment.
Still happens (on master). One thread is busy waiting in retry loop of GC_stop_world, the rest threads hang in sigsuspend, |
Observed on the latest master: https://travis-ci.org/ivmai/bdwgc/jobs/333495385 |
Latest fail: https://travis-ci.org/ivmai/bdwgc/jobs/357279589 |
…TSan (fix of commit af409e4) Issue #181 (bdwgc). This change is to do as less as possible (even in case of TSan usage) between the sem_post and sigsuspend calls in GC_suspend_handler_inner (to match the relevant comment after sigsuspend call). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Move sigemptyset() and pthread_sigmask() calls to be just before sem_post() call.
Issue #181 (bdwgc). Also, one sem_t variable is used to acknowledge both thread suspends and restarts. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_ack_sem): Add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_restart_ack_sem): Remove static variable. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_suspend_handler_inner): Call sem_post(&GC_suspend_ack_sem) at the end of the handler (just before RESTORE_CANCEL). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (suspend_restart_barrier): New static function. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_restart_handler): Do not call sem_post(&GC_restart_ack_sem). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Remove i, code local variables; call suspend_restart_barrier instead of sem_wait calls in a loop. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Likewise. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_NETBSD_THREADS_WORKAROUND] (GC_stop_init): Remove sem_init(&GC_restart_ack_sem) call.
Also observed with MSan: https://travis-ci.org/ivmai/bdwgc/jobs/359743820 |
Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && THREAD_SANITIZER] (GC_suspend_handler_inner): Replace pthread_sigmask(SIG_SETMASK) to pthread_sigmask(SIG_UNBLOCK) with the set with GC_sig_suspend and GC_sig_thr_restart signals.
(code refactoring) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ASSERTIONS] (suspend_restart_barrier): Check that the count of GC_suspend_ack_sem is zero at the end of the function. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (resend_lost_signals): New static function (the code is moved from GC_stop_world). * pthread_stop_world.c [DEBUG_THREADS] (GC_suspend_all): Move the assignment of GC_stopping_thread and GC_stopping_pid to GC_stop_world. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Call resend_lost_signals() if GC_retry_signals. * pthread_stop_world.c [!NACL] (GC_restart_all): New static function (the code is moved from GC_start_world). * pthread_stop_world.c [!NACL] (GC_start_world): Declare n_live_threads local variable; call GC_restart_all.
Issue #181 (bdwgc). * doc/README.environment (GC_RETRY_SIGNALS, GC_NO_RETRY_SIGNALS): Update documentation (support of restart signals loss, try signals if compiled with ASan/MSan/TSan). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_retry_signals): Set true also if ADDRESS_SANITIZER or MEMORY_SANITIZER. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_NETBSD_THREADS_WORKAROUND] (GC_suspend_handler_inner): Call sem_post(GC_suspend_ack_sem) at the function end if GC_retry_signals; update comment about the RESTART signal loss. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_OPENBSD_UTHREADS] (GC_start_world): Call resend_lost_signals(GC_restart_all) and update n_live_threads value. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && !GC_OPENBSD_UTHREADS && !GC_NETBSD_THREADS_WORKAROUND] (GC_start_world): Call suspend_restart_barrier() if GC_retry_signals. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_init): Update the message logged if GC_retry_signals.
This issue should be fixed now. |
(fix of commit 3498427) Issue #181 (bdwgc). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_count): Update comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Add assertion that my_stop_count is even. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Mask lowest bit of last_stop_count when checking for the duplicate signal. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): If GC_retry_signals then set the lowest bit of last_stop_count (by AO_store_release) after the second sem_post() call; add comment. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_all): Add comment for last_stop_count check. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_stop_world): Increment GC_stop_count by 2 (instead of by one). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_restart_all): If GC_retry_signals and last_stop_count has the same value as GC_stop_count+1 then do not increment n_live_threads and do not send the restart signal to the thread.
How to reproduce:
./configure --disable-parallel-mark && make -j check CC=clang-4.0 CFLAGS_EXTRA="-fsanitize=thread -DNO_CANCEL_SAFE -DDEBUG_THREADS"
Host: Ubuntu/x64
Source: master branch
The reason: signals are not delivered.
I found a topic about signals delivery in Thread Sanitizer: https://groups.google.com/forum/#!topic/thread-sanitizer/xtSQQQPcIfs
The text was updated successfully, but these errors were encountered: