From 47fe18bf3677d4eb34080be771d5d62d7124a527 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 29 May 2009 13:31:53 -0700 Subject: [PATCH] Fix godoc deadlock. The code was already careful not to use malloc/free for stack growth during calls to malloc. Avoid them during calls to free too. R=r DELTA=9 (7 added, 0 deleted, 2 changed) OCL=29606 CL=29610 --- src/runtime/malloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/runtime/malloc.c b/src/runtime/malloc.c index 5f23f0f645..b33cc6fe25 100644 --- a/src/runtime/malloc.c +++ b/src/runtime/malloc.c @@ -28,7 +28,7 @@ malloc(uintptr size) uint32 *ref; if(m->mallocing) - throw("malloc - deadlock"); + throw("malloc/free - deadlock"); m->mallocing = 1; if(size == 0) @@ -89,6 +89,10 @@ free(void *v) if(v == nil) return; + if(m->mallocing) + throw("malloc/free - deadlock"); + m->mallocing = 1; + mlookup(v, nil, nil, &ref); *ref = RefFree; @@ -106,7 +110,7 @@ free(void *v) mstats.alloc -= s->npages<npages<mallocing = 0; } int32 -- 2.48.1