Fix some checkleveldeep assertions:

1. In GlobalsPrepareToDestroy, set arenaGlobals->defaultChain to NULL before calling ChainDestroy, to avoid a failed ChainCheck inside ControlFree.
2. In GlobalsPrepareToDestroy, set arenaGlobals->lock to NULL after destroying it, to avoid a failed LockCheck inside ControlFree.
3. In TraceIdMessagesCreate, set tsMessage[ti] and tMessage[ti] together to avoid a failed TraceIdMessagesCheck inside traceMessageInit.
4. In TracePostStartMessage, set tsMessage[ti] to NULL before calling MessagePost, to avoid a failed TraceStartMessageCheck inside ControlFree.
5. Ditto for TracePostMessage and tMessage[ti].

Copied from Perforce
 Change: 184924
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2014-03-20 23:37:02 +00:00
parent 6e07f248cd
commit cb17267a8e
2 changed files with 12 additions and 8 deletions

View file

@ -1,7 +1,7 @@
/* global.c: ARENA-GLOBAL INTERFACES
*
* $Id$
* Copyright (c) 2001-2013 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*
* .sources: See <design/arena/>. design.mps.thread-safety is relevant
@ -441,20 +441,23 @@ void GlobalsPrepareToDestroy(Globals arenaGlobals)
Arena arena;
TraceId ti;
Trace trace;
Chain defaultChain;
AVERT(Globals, arenaGlobals);
arena = GlobalsArena(arenaGlobals);
arenaDenounce(arena);
ChainDestroy(arenaGlobals->defaultChain);
defaultChain = arenaGlobals->defaultChain;
arenaGlobals->defaultChain = NULL;
ChainDestroy(defaultChain);
LockReleaseMPM(arenaGlobals->lock);
/* Theoretically, another thread could grab the lock here, but it's */
/* not worth worrying about, since an attempt after the lock has been */
/* destroyed would lead to a crash just the same. */
LockFinish(arenaGlobals->lock);
arenaGlobals->lock = NULL;
TRACE_SET_ITER(ti, trace, TraceSetUNIV, arena)
/* <design/message-gc/#lifecycle> */
@ -1140,7 +1143,7 @@ Bool ArenaEmergency(Arena arena)
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2013 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*

View file

@ -1,7 +1,7 @@
/* traceanc.c: ANCILLARY SUPPORT FOR TRACER
*
* $Id$
* Copyright (c) 2001-2013 Ravenbrook Limited.
* Copyright (c) 2001-2014 Ravenbrook Limited.
* See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*
@ -239,8 +239,8 @@ void TracePostStartMessage(Trace trace)
traceStartWhyToTextBuffer(tsMessage->why,
sizeof tsMessage->why, trace->why);
MessagePost(arena, TraceStartMessageMessage(tsMessage));
arena->tsMessage[ti] = NULL;
MessagePost(arena, TraceStartMessageMessage(tsMessage));
} else {
arena->droppedMessages += 1;
}
@ -406,8 +406,8 @@ void TracePostMessage(Trace trace)
tMessage->condemnedSize = trace->condemned;
tMessage->notCondemnedSize = trace->notCondemned;
MessagePost(arena, TraceMessageMessage(tMessage));
arena->tMessage[ti] = NULL;
MessagePost(arena, TraceMessageMessage(tMessage));
} else {
arena->droppedMessages += 1;
}
@ -479,10 +479,11 @@ Res TraceIdMessagesCreate(Arena arena, TraceId ti)
traceStartMessageInit(arena, tsMessage);
AVERT(TraceStartMessage, tsMessage);
arena->tsMessage[ti] = tsMessage;
traceMessageInit(arena, tMessage);
AVERT(TraceMessage, tMessage);
arena->tsMessage[ti] = tsMessage;
arena->tMessage[ti] = tMessage;
AVER(TraceIdMessagesCheck(arena, ti));
@ -793,7 +794,7 @@ static void arenaForgetProtection(Globals globals)
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2013 Ravenbrook Limited
* Copyright (C) 2001-2014 Ravenbrook Limited
* <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.