[PATCH] D51196: Add a RingBuffer class to sanitizer_common

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 28 15:41:46 PDT 2018


eugenis added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_ring_buffer.h:30
+    RB->last_ = RB->next_ = reinterpret_cast<T*>(End - sizeof(T));
+    CHECK_GE(sizeof(T), sizeof(void*));
+    return RB;
----------------
I think you need to check that sizeof(T) is divisible by sizeof(void*), otherwise wrap-around check is not correct.


================
Comment at: lib/sanitizer_common/sanitizer_ring_buffer.h:51
+    CHECK_LT(Idx, size());
+    T *Ptr = next_ + 1 + Idx;
+    if (Ptr > last_)
----------------
I think this is UB.


================
Comment at: lib/sanitizer_common/sanitizer_ring_buffer.h:59
+  RingBuffer() {}
+  ~RingBuffer() {}
+
----------------
delete copy constructor?


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D51196





More information about the llvm-commits mailing list