[PATCH] D53528: [sanitizer] Avoid calling a nullptr in MonotonicNanoTime if interceptors are not yet initialized
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 24 11:42:23 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345174: [sanitizer] Avoid calling a nullptr in MonotonicNanoTime if interceptors areā¦ (authored by kuba.brecka, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D53528?vs=170662&id=170939#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53528
Files:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ compiler-rt/trunk/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.170939.patch
Type: text/x-patch
Size: 1076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181024/f5855405/attachment.bin>
More information about the llvm-commits
mailing list