[PATCH] D53528: [sanitizer] Avoid calling a nullptr in MonotonicNanoTime if interceptors are not yet initialized
Kuba (Brecka) Mracek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 23 08:48:14 PDT 2018
kubamracek updated this revision to Diff 170662.
https://reviews.llvm.org/D53528
Files:
lib/sanitizer_common/sanitizer_linux_libcdep.cc
Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -782,12 +782,15 @@
// MonotonicNanoTime is a timing function that can leverage the vDSO by calling
// clock_gettime. real_clock_gettime only exists if clock_gettime is
-// intercepted, so define it weakly and use it if available.
+// intercepted, so define it weakly and use it if available. MonotonicNanoTime
+// might also be called when interceptors are not yet initialized, so check for
+// that as well.
extern "C" SANITIZER_WEAK_ATTRIBUTE
int real_clock_gettime(u32 clk_id, void *tp);
+namespace __interception { int (*real_clock_gettime)(u32 clk_id, void *tp); }
u64 MonotonicNanoTime() {
timespec ts;
- if (CanUseVDSO()) {
+ if (CanUseVDSO() && __interception::real_clock_gettime) {
if (&real_clock_gettime)
real_clock_gettime(CLOCK_MONOTONIC, &ts);
else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53528.170662.patch
Type: text/x-patch
Size: 1022 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181023/f1f80a0b/attachment.bin>
More information about the llvm-commits
mailing list