aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.goc
diff options
context:
space:
mode:
authorDmitriy Vyukov <dvyukov@google.com>2013-07-17 12:52:37 -0400
committerRuss Cox <rsc@golang.org>2013-07-17 12:52:37 -0400
commit5887f142a33fbb8da94088e902ced4101a16aa8f (patch)
tree34e4b531885ee16e020a5fc0289a4836f561f7ed /src/pkg/runtime/malloc.goc
parenta83748596c009db47bcd35a69531e485e2c7f924 (diff)
downloadgo-5887f142a33fbb8da94088e902ced4101a16aa8f.tar.xz
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
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
-rw-r--r--src/pkg/runtime/malloc.goc3
1 files changed, 3 insertions, 0 deletions
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)