Assert that we don't try to have an ArenaBlock depend on itself.

It introduces a cycle in the `next` pointers in the ArenaBlockRef's,
which results in infinite recursion as we follow them in `getTotalSize`.

This doesn't fix the underlying problem, but gives a better failure
than a stack overflow.
This commit is contained in:
Dan Adkins 2022-11-03 16:31:01 -07:00
parent c489dbcb26
commit 2a8f5c7c3c
1 changed files with 2 additions and 1 deletions

View File

@ -297,6 +297,7 @@ void* ArenaBlock::make4kAlignedBuffer(uint32_t size) {
}
void ArenaBlock::dependOn(Reference<ArenaBlock>& self, ArenaBlock* other) {
ASSERT(self->getData() != other->getData());
other->addref();
if (!self || self->isTiny() || self->unused() < sizeof(ArenaBlockRef))
create(SMALL, self)->makeReference(other);