MPS issue job003502

TitleRace condition in EventInit()
Statusclosed
Prioritynice
Assigned userGareth Rees
OrganizationRavenbrook
DescriptionThere is only one event system (shared between all arenas) and so EventInit() needs to run only once even if there are multiple arenas. Its initialization is guarded with

    if(!eventInited) {
        /* ... */
        eventInited = TRUE;
    }

but this is obviously not safe if two threads create arenas at the same time.
AnalysisA special case of job003387.

We could take the global binary lock while initializing the event system.
How foundinspection
Evidence[1] //info.ravenbrook.com/project/mps/master/code/event.c
Observed in1.111.0
Created byGareth Rees
Created on2013-05-30 14:46:17
Last modified byRichard Brooksby
Last modified on2016-04-12 18:16:06
History2013-05-30 GDR Created

Fixes

Change Effect Date User Description
191018 closed 2016-04-12 18:16:06 Richard Brooksby Guarding EventInit with the global lock, and removing the enforcement of the reference count, so that the event system can be used from classes, which get called before any arena.