[compiler-rt] [scudo] Allow to resize allocation ring buffer (PR #82683)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 15:57:23 PST 2024


================
@@ -1564,11 +1570,11 @@ class Allocator {
                   UINTPTR_MAX);
----------------
ChiaHungDuan wrote:

I mean, from the statements,
```
static_assert(sizeof(StackDepot) % alignof(atomic_u64) == 0);
```
```
static_assert(sizeof(StackDepot) + UINT32_MAX * sizeof(atomic_u64) *
                                           UINT32_MAX * sizeof(atomic_u32) < UINTPTR_MAX);
```
They are checking things independent to `RingSize` and `TabSize` here. The checks don't need the value of two variables. Any values of RingSize/TabSize will static assert the same thing. They are general constraints for StackDepot.

The expression results in a number larger than uint32_t but it'll wrap-around and the value will always be in the range of uint32_t. When it compares with UINTPTR_MAX, it's almost always true on 32 bit and always true on 64 bit. static_assert doesn't help with this.

In addition, even the `StackDepot meets the requirement, you still can't allocate ring buffer with UINT32_MAX. This seems to be an unreasonable assertion.

https://github.com/llvm/llvm-project/pull/82683


More information about the llvm-commits mailing list