[PATCH] D54889: Fiber support for thread sanitizer

Dmitry Vyukov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 11 06:48:01 PST 2019


dvyukov added a comment.

In D54889#1392723 <https://reviews.llvm.org/D54889#1392723>, @yuri wrote:

> In D54889#1392721 <https://reviews.llvm.org/D54889#1392721>, @dvyukov wrote:
>
> > However, for thread initialization we rely on the fact that pthread's thread entry function (start_thread) calls _setjmp which we intercept. If start_thread does not call _setjmp then we risk to hit NULL cur_thread in secondary threads. I think we need to add cur_thread_init also to:
> >
> > 1. SCOPED_INTERCEPTOR_RAW (this will ensure that if start_thread calls any intercepted libc function, we will init at that point)
>
>
> There is a lot if interceptors that do
>
>   if (cur_thread()->in_symbolizer)
>
> before SCOPED_INTERCEPTOR_RAW. What to do with them?


Yikes! Good question!

If we are in the symbolize we've already initialized cur_thread, since we are coming recursively from runtime. But this does not help because if we are not in symbolizer, we can have cur_thread not initialized...

We have it in malloc, atexit and similar fundamental functions that can well be a function called during process or thread start.

All of in_symbolizer checks call cur_thread in the same expression rather than use some local variable, i.e. they are of the form:

if (cur_thread()->in_symbolizer)

which suggests that we should introduce a helper in_symbolizer(void) function that will incapsulate cur_thread_init and the check (probably should go into tsan_interceptors.h).
Please send a separate change that adds such helper function and then this change will just add cur_thread_init to that function.


Repository:
  rCRT Compiler Runtime

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54889/new/

https://reviews.llvm.org/D54889





More information about the llvm-commits mailing list