[compiler-rt] Fall back to internal_uname() when called early
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 27 Mar 2020 19:23:20 +0000 (20:23 +0100)
committerIlya Leoshkevich <iii@linux.ibm.com>
Sat, 28 Mar 2020 02:14:19 +0000 (03:14 +0100)
commitfad47d222561f0672223b0b3304ff1c739cb3288
treef91e5b5e97c0cef094254bef2f1e312a40f2147e
parent0c42539df3d4c697fa3bf6fc88e94b127d334a57
[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
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc