From 85126d5203ec5344f6a5b2e77da23d34444e48c6 Mon Sep 17 00:00:00 2001 From: stolz Date: Tue, 23 Apr 2002 09:56:29 +0000 Subject: [PATCH] [project @ 2002-04-23 09:56:28 by stolz] - set thread labels to NULL after free() - labelThread# didn't exit properly TODO: Labels are prematurely free()d when a thread terminates. Better let the GC worry? --- ghc/rts/PrimOps.hc | 3 ++- ghc/rts/Schedule.c | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ghc/rts/PrimOps.hc b/ghc/rts/PrimOps.hc index d31e842..5183a9c 100644 --- a/ghc/rts/PrimOps.hc +++ b/ghc/rts/PrimOps.hc @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: PrimOps.hc,v 1.95 2002/04/10 11:43:45 stolz Exp $ + * $Id: PrimOps.hc,v 1.96 2002/04/23 09:56:29 stolz Exp $ * * (c) The GHC Team, 1998-2000 * @@ -1046,6 +1046,7 @@ FN_(labelThreadzh_fast) #ifdef DEBUG STGCALL2(labelThread,CurrentTSO,(char *)R1.p); #endif + JMP_(ENTRY_CODE(Sp[0])); FE_ } diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index 2601f7d..72229d4 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -1,5 +1,5 @@ /* --------------------------------------------------------------------------- - * $Id: Schedule.c,v 1.138 2002/04/23 06:34:27 sof Exp $ + * $Id: Schedule.c,v 1.139 2002/04/23 09:56:28 stolz Exp $ * * (c) The GHC Team, 1998-2000 * @@ -443,6 +443,7 @@ schedule( void ) broadcastCondition(&m->wakeup); #ifdef DEBUG free(m->tso->label); + m->tso->label = NULL; #endif break; case ThreadKilled: @@ -456,6 +457,7 @@ schedule( void ) broadcastCondition(&m->wakeup); #ifdef DEBUG free(m->tso->label); + m->tso->label = NULL; #endif break; default: @@ -478,6 +480,7 @@ schedule( void ) || m->tso->what_next == ThreadKilled) { #ifdef DEBUG free(m->tso->label); + m->tso->label = NULL; #endif main_threads = main_threads->link; if (m->tso->what_next == ThreadComplete) { @@ -1635,6 +1638,7 @@ void labelThread(StgTSO *tso, char *label) if (buf == NULL) { fprintf(stderr,"insufficient memory for labelThread!\n"); free(tso->label); + tso->label = NULL; } else strncpy(buf,label,len); tso->label = buf; -- 1.7.10.4