From cb17267a8e4dec98282ea87ef67b7b43c8f54f8d Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Thu, 20 Mar 2014 23:37:02 +0000 Subject: [PATCH] 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 --- mps/code/global.c | 9 ++++++--- mps/code/traceanc.c | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mps/code/global.c b/mps/code/global.c index ca0946ae9af..0bf481cb136 100644 --- a/mps/code/global.c +++ b/mps/code/global.c @@ -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.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) /* */ @@ -1140,7 +1143,7 @@ Bool ArenaEmergency(Arena arena) /* C. COPYRIGHT AND LICENSE * - * Copyright (C) 2001-2013 Ravenbrook Limited . + * Copyright (C) 2001-2014 Ravenbrook Limited . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options. * diff --git a/mps/code/traceanc.c b/mps/code/traceanc.c index a383d71955c..675e18e1f95 100644 --- a/mps/code/traceanc.c +++ b/mps/code/traceanc.c @@ -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 * . * All rights reserved. This is an open source license. Contact * Ravenbrook for commercial licensing options.