[compiler-rt] fad47d2 - [compiler-rt] Fall back to internal_uname() when called early
Ilya Leoshkevich via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 19:15:05 PDT 2020
Author: Ilya Leoshkevich
Date: 2020-03-28T03:14:19+01:00
New Revision: fad47d222561f0672223b0b3304ff1c739cb3288
URL: https://github.com/llvm/llvm-project/commit/fad47d222561f0672223b0b3304ff1c739cb3288
DIFF: https://github.com/llvm/llvm-project/commit/fad47d222561f0672223b0b3304ff1c739cb3288.diff
LOG: [compiler-rt] Fall back to internal_uname() when called early
Summary:
Commit 5f5fb56c68e4 ("[compiler-rt] Intercept the uname() function")
broke sanitizer-x86_64-linux and clang-cmake-thumbv7-full-sh (again)
builds:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/26313
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-full-sh/builds/4324
The reason is that uname() can be called as early as
__pthread_initialize_minimal_internal(). When intercepted, this
triggers ASan initialization, which eventually calls dlerror(), which
in turn uses pthreads, causing all sorts of issues.
Fix by falling back to internal_uname() when interceptor runs before
ASan is initialized. This is only for Linux at the moment.
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: dberris, #sanitizers, pcc
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D76919
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index 1671273174de..0ca86dee69a3 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -9748,6 +9748,10 @@ INTERCEPTOR(int, sigaltstack, void *ss, void *oss) {
#if SANITIZER_INTERCEPT_UNAME
INTERCEPTOR(int, uname, struct utsname *utsname) {
+#if SANITIZER_LINUX
+ if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+ return internal_uname(utsname);
+#endif
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, uname, utsname);
int res = REAL(uname)(utsname);
More information about the llvm-commits
mailing list