From 5887f142a33fbb8da94088e902ced4101a16aa8f Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Wed, 17 Jul 2013 12:52:37 -0400 Subject: runtime: more reliable preemption Currently preemption signal g->stackguard0==StackPreempt can be lost if it is received when preemption is disabled (e.g. m->lock!=0). This change duplicates the preemption signal in g->preempt and restores g->stackguard0 when preemption is enabled. Update #543. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/10792043 --- src/pkg/runtime/malloc.goc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pkg/runtime/malloc.goc') diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 0347b90c91..78535c61f0 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -13,6 +13,7 @@ package runtime #include "type.h" #include "typekind.h" #include "race.h" +#include "stack.h" MHeap runtime·mheap; @@ -94,6 +95,8 @@ runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed) *(uintptr*)((uintptr)v+size-sizeof(uintptr)) = 0; m->mallocing = 0; + if(g->preempt) // restore the preemption request in case we've cleared it in newstack + g->stackguard0 = StackPreempt; if(!(flag & FlagNoProfiling) && (rate = runtime·MemProfileRate) > 0) { if(size >= rate) -- cgit v1.3