From b3e8eb2280594da3cc45bc98ed8268fa36d2a2ad Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 7 Aug 2015 16:14:50 +0100 Subject: [PATCH] The primary chunk is always the last chunk to be removed, so assert that. review suggestion from rb; see Copied from Perforce Change: 188089 ServerID: perforce.ravenbrook.com --- mps/code/arena.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mps/code/arena.c b/mps/code/arena.c index 6327b791b59..95355935c57 100644 --- a/mps/code/arena.c +++ b/mps/code/arena.c @@ -701,12 +701,16 @@ void ArenaChunkRemoved(Arena arena, Chunk chunk) AVERT(Arena, arena); AVERT(Chunk, chunk); - if (arena->primary == chunk) - arena->primary = NULL; - size = ChunkReserved(chunk); AVER(arena->reserved >= size); arena->reserved -= size; + + if (chunk == arena->primary) { + /* The primary chunk must be the last chunk to be removed. */ + AVER(RingIsSingle(&arena->chunkRing)); + AVER(arena->reserved == 0); + arena->primary = NULL; + } }