[compiler-rt] [scudo] [MTE] resize stack depot for allocation ring buffer (PR #74515)
Christopher Ferris via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 19:06:14 PST 2023
================
@@ -62,47 +63,103 @@ class StackDepot {
// This is achieved by re-checking the hash of the stack trace before
// returning the trace.
-#if SCUDO_SMALL_STACK_DEPOT
- static const uptr TabBits = 4;
-#else
- static const uptr TabBits = 16;
-#endif
- static const uptr TabSize = 1 << TabBits;
- static const uptr TabMask = TabSize - 1;
- atomic_u32 Tab[TabSize] = {};
-
-#if SCUDO_SMALL_STACK_DEPOT
- static const uptr RingBits = 4;
-#else
- static const uptr RingBits = 19;
-#endif
- static const uptr RingSize = 1 << RingBits;
- static const uptr RingMask = RingSize - 1;
- atomic_u64 Ring[RingSize] = {};
+ uptr RingSize = 0;
+ uptr RingMask = 0;
+ uptr TabMask = 0;
+ // This is immediately followed by RingSize atomic_u64 and
+ // (TabMask + 1) atomic_u32.
+
+ atomic_u64 *Ring(char *RawStackDepot) {
+ return reinterpret_cast<atomic_u64 *>(RawStackDepot + sizeof(StackDepot));
+ }
+
+ atomic_u32 *Tab(char *RawStackDepot) {
+ return reinterpret_cast<atomic_u32 *>(RawStackDepot + sizeof(StackDepot) +
----------------
cferris1000 wrote:
Any chance that these values could ever overflow? I know you are planning to allow the setting of the ring buffersize, but since everything is calculated from that value, I don't think an overflow should be possible.
https://github.com/llvm/llvm-project/pull/74515
More information about the llvm-commits
mailing list