Index: compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -7777,9 +7777,18 @@ COMMON_INTERCEPTOR_READ_RANGE(ctx, preg, struct_regex_sz); REAL(regfree)(preg); } + +#ifdef SANITIZER_REGEXEC_VERSION +#define COMMON_INTERCEPT_FUNCTION_REGEXEC(fn) \ + COMMON_INTERCEPT_FUNCTION_VER(fn, SANITIZER_REGEXEC_VERSION) +#else +#define COMMON_INTERCEPT_FUNCTION_REGEXEC(fn) \ + COMMON_INTERCEPT_FUNCTION(fn) +#endif + #define INIT_REGEX \ COMMON_INTERCEPT_FUNCTION(regcomp); \ - COMMON_INTERCEPT_FUNCTION(regexec); \ + COMMON_INTERCEPT_FUNCTION_REGEXEC(regexec); \ COMMON_INTERCEPT_FUNCTION(regerror); \ COMMON_INTERCEPT_FUNCTION(regfree); #else Index: compiler-rt/lib/sanitizer_common/sanitizer_platform.h =================================================================== --- compiler-rt/lib/sanitizer_common/sanitizer_platform.h +++ compiler-rt/lib/sanitizer_common/sanitizer_platform.h @@ -335,6 +335,12 @@ #define SANITIZER_NLDBL_VERSION "GLIBC_2.4" #endif +// On linux, we need a recent regexec implementation that supports +// a non-POSIX flag REG_STARTEND. +#if SANITIZER_LINUX +#define SANITIZER_REGEXEC_VERSION "GLIBC_2.3.4" +#endif + #if SANITIZER_GO == 0 # define SANITIZER_GO 0 #endif