]> Cypherpunks repositories - gostls13.git/commitdiff
Fix godoc deadlock.
authorRuss Cox <rsc@golang.org>
Fri, 29 May 2009 20:31:53 +0000 (13:31 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 29 May 2009 20:31:53 +0000 (13:31 -0700)
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

index 5f23f0f6451d41dd8420c758c5c185ed06c568ac..b33cc6fe25ce93b29c19fa838e86a17f4ddc81df 100644 (file)
@@ -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<<PageShift;
                        sys_memclr(v, s->npages<<PageShift);
                        MHeap_Free(&mheap, s);
-                       return;
+                       goto out;
                }
                MHeapMapCache_SET(&mheap.mapcache, page, sizeclass);
        }
@@ -117,6 +121,9 @@ free(void *v)
        sys_memclr(v, size);
        mstats.alloc -= size;
        MCache_Free(c, v, sizeclass, size);
+
+out:
+       m->mallocing = 0;
 }
 
 int32