]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: serialize mcache allocation
authorRuss Cox <rsc@golang.org>
Thu, 30 Sep 2010 18:09:19 +0000 (14:09 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 30 Sep 2010 18:09:19 +0000 (14:09 -0400)
Fixes racy regex-dna-parallel crashes.

R=r, r2
CC=golang-dev
https://golang.org/cl/2308042

src/pkg/runtime/malloc.goc

index fa7164ec57a1a4f01d7994e4492f8cc7492a88f9..604290b93b99b66c1802772ad6e167fd8c46df72 100644 (file)
@@ -236,9 +236,11 @@ allocmcache(void)
 {
        MCache *c;
 
+       lock(&mheap);
        c = FixAlloc_Alloc(&mheap.cachealloc);
        mstats.mcache_inuse = mheap.cachealloc.inuse;
        mstats.mcache_sys = mheap.cachealloc.sys;
+       unlock(&mheap);
        return c;
 }