[compiler-rt] r267793 - [sanitizer] Add early call handling to strchr + strrchr interceptors
Derek Bruening via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 14:20:46 PDT 2016
Author: bruening
Date: Wed Apr 27 16:20:46 2016
New Revision: 267793
URL: http://llvm.org/viewvc/llvm-project?rev=267793&view=rev
Log:
[sanitizer] Add early call handling to strchr + strrchr interceptors
Summary:
The strchr and strrchr interceptors are sometimes invoked too early
for their REAL() counterparts to be initialized. We have seen this in
hooks invoked from tcmalloc on the dlsym() used in initializing
interceptors. A special check is added to use internal_ routines for
this situation.
Reviewers: vitalybuka, aizatsky, filcab
Subscribers: filcab, llvm-commits, eugenis, kcc, zhaoqin, aizatsky, kubabrecka
Differential Revision: http://reviews.llvm.org/D19607
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc?rev=267793&r1=267792&r2=267793&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interceptors.inc Wed Apr 27 16:20:46 2016
@@ -401,6 +401,8 @@ INTERCEPTOR(char*, strcasestr, const cha
#if SANITIZER_INTERCEPT_STRCHR
INTERCEPTOR(char*, strchr, const char *s, int c) {
void *ctx;
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_strchr(s, c);
COMMON_INTERCEPTOR_ENTER(ctx, strchr, s, c);
char *result = REAL(strchr)(s, c);
uptr len = internal_strlen(s);
@@ -432,6 +434,8 @@ INTERCEPTOR(char*, strchrnul, const char
#if SANITIZER_INTERCEPT_STRRCHR
INTERCEPTOR(char*, strrchr, const char *s, int c) {
void *ctx;
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_strrchr(s, c);
COMMON_INTERCEPTOR_ENTER(ctx, strrchr, s, c);
uptr len = internal_strlen(s);
if (common_flags()->intercept_strchr)
More information about the llvm-commits
mailing list