[compiler-rt] r193519 - tsan: start the background thread with signals blocked, otherwise it can steal users signals

Reid Kleckner rnk at google.com
Tue Oct 29 13:15:32 PDT 2013


Can a signal be delivered to the child during startup?  I've observed this
in DR and it gave me a lot of pain.  Maybe a more robust way to do this
would be to:

1. block signals in parent, save old sigset
2. spawn child thread with signals blocked (I think it uses the parent's
set?)
3. unblock signals in the parent


On Mon, Oct 28, 2013 at 8:29 AM, Dmitry Vyukov <dvyukov at google.com> wrote:

> Author: dvyukov
> Date: Mon Oct 28 07:29:32 2013
> New Revision: 193519
>
> URL: http://llvm.org/viewvc/llvm-project?rev=193519&view=rev
> Log:
> tsan: start the background thread with signals blocked, otherwise it can
> steal users signals
>
>
> Modified:
>     compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
>
> Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=193519&r1=193518&r2=193519&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
> +++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Mon Oct 28
> 07:29:32 2013
> @@ -2191,9 +2191,15 @@ void InitializeInterceptors() {
>  }
>
>  void internal_start_thread(void(*func)(void *arg), void *arg) {
> +  // Start the thread with signals blocked, otherwise it can steal users
> +  // signals.
> +  __sanitizer_kernel_sigset_t set, old;
> +  internal_sigfillset(&set);
> +  internal_sigprocmask(SIG_SETMASK, &set, &old);
>    void *th;
>    REAL(pthread_create)(&th, 0, (void*(*)(void *arg))func, arg);
>    REAL(pthread_detach)(th);
> +  internal_sigprocmask(SIG_SETMASK, &old, 0);
>  }
>
>  }  // namespace __tsan
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131029/85839512/attachment.html>


More information about the llvm-commits mailing list