[tsan] Allow memchr interceptor to be used before initialization on OS X

On OS X, `memchr` is called on a newly created thread even before `__tsan_thread_start_func` is invoked, which means that the ThreadState object for that thread will not yet be initialized. Let's add `COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED` into the interceptor to simply call `internal_memchr` in these cases.

Differential Revision: http://reviews.llvm.org/D14283

llvm-svn: 251935
This commit is contained in:
Kuba Brecka 2015-11-03 16:19:37 +00:00
parent a4a227f7e8
commit 77f16f369b
1 changed files with 2 additions and 0 deletions

View File

@ -441,6 +441,8 @@ INTERCEPTOR(int, memcmp, const void *a1, const void *a2, uptr size) {
#if SANITIZER_INTERCEPT_MEMCHR
INTERCEPTOR(void*, memchr, const void *s, int c, SIZE_T n) {
if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
return internal_memchr(s, c, n);
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, memchr, s, c, n);
void *res = REAL(memchr)(s, c, n);