From e943c43f3d673beebff117b660ba45cefc246ad0 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 5 Feb 2007 10:21:02 +0000 Subject: [PATCH] fix memory leak in allocExec/freeExec (see bug #985) --- rts/sm/Storage.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c index 6e862f2..097c727 100644 --- a/rts/sm/Storage.c +++ b/rts/sm/Storage.c @@ -1046,13 +1046,17 @@ void freeExec (void *addr) bd->gen_no -= *(StgPtr)p; *(StgPtr)p = 0; - // Free the block if it is empty, but not if it is the block at - // the head of the queue. - if (bd->gen_no == 0 && bd != exec_block) { - debugTrace(DEBUG_gc, "free exec block %p", bd->start); - dbl_link_remove(bd, &exec_block); - setExecutable(bd->start, bd->blocks * BLOCK_SIZE, rtsFalse); - freeGroup(bd); + if (bd->gen_no == 0) { + // Free the block if it is empty, but not if it is the block at + // the head of the queue. + if (bd != exec_block) { + debugTrace(DEBUG_gc, "free exec block %p", bd->start); + dbl_link_remove(bd, &exec_block); + setExecutable(bd->start, bd->blocks * BLOCK_SIZE, rtsFalse); + freeGroup(bd); + } else { + bd->free = bd->start; + } } RELEASE_SM_LOCK -- 1.7.10.4