Each of the multithreaded tasks gets it's memory using BeginTemporaryMemory in BeginTaskWithMemory, and releases it with EndTemporaryMemory in EndTaskWithMemory.
BeginTemporaryMemory returns a temporary_memory structure which contains the arena and the amount of it used at the time it is called. When EndTemporaryMemory is called passing that temporary_memory structure back, the arena's Used structure member is reset to what is was before, effectively freeing the temporary memory.
But what happens when one task gets temporary memory, say temp1, with temp1.Used == 2000, then another task gets temp2 with temp2.Used == 2200 and temp1 is freed before temp2.
arena->Used will be set to 2000, then when temp2 tries to free it's memory, it will try to set arena->Used to 2200, effectively a memory allocation.
When this happens the assert in EndTemporaryMemory (Arena->Used >= TempMem.Used) will fire.
Am I understanding this properly?