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.