MPS issue job003495

TitleAssertion failure if you try to create a small arena
Assigned userGareth Rees
DescriptionMMQA test function/121 [1] tries to create a virtual memory arena with initial size 65536. It fails with this assertion:

    arena.c:131: MPS ASSERTION FAILED: ((Size)1 << arena->zoneShift) >= arena->alignment

There are three problems with this:

1. There's no indication in the documentation that creating a small arena might fail.

2. Failing with an assertion rather than returning MPS_RES_PARAM is naughty.

3. Why does this have to fail anyway? It's a virtual memory arena that's capable of extending itself if need be, so why not just round up to minimum size?

(Originally reported by RIT [2].)
AnalysisThe minimum size of a virtual memory arena is pagesize * MPS_WORD_WIDTH -- on 64-bit OS X that's 4096 * 64 = 262144.

ArenaCreate tries to return a result code (ResMEMORY though) but because it only detects the problem after it has called class->init (VMArenaInit in this case), it has to call class->finish (VMArenaFinish in this case), and the first thing that VMArenaFinish does is AVERT(Arena, arena) which calls ArenaCheck which asserts.
How foundautomated_test
Observed in1.111.0
Created byGareth Rees
Created on2013-05-25 20:06:46
Last modified byGareth Rees
Last modified on2014-10-08 22:16:56
History2013-05-25 GDR Created.


Change Effect Date User Description
187164 closed 2014-10-08 22:16:56 Gareth Rees If you try to create a client arena that's too small for the full complement of zones, return MPS_RES_MEMORY instead of asserting.
If you try to create a virtual memory arena that's too small for the full complement of zones, round up the size to the minimum instead of asserting.