From 7389ab8d218fe7b7cf2ebdd232524a1ebd5a0b81 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 30 Sep 2010 14:09:19 -0400 Subject: [PATCH] runtime: serialize mcache allocation Fixes racy regex-dna-parallel crashes. R=r, r2 CC=golang-dev https://golang.org/cl/2308042 --- src/pkg/runtime/malloc.goc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index fa7164ec57a..604290b93b9 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -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; }