1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:30:25 -07:00

runtime: fix racefuncenter argument corruption.

Revision 6a88e1893941 corrupts the argument to
racefuncenter by pushing the data block pointer
to the stack.

Fixes #4885.

R=dvyukov, rsc
CC=golang-dev
https://golang.org/cl/7381053
This commit is contained in:
Rémy Oudompheng 2013-02-28 07:32:29 +01:00
parent b2249f2018
commit e2f9e816b7
2 changed files with 9 additions and 11 deletions

View File

@ -94,10 +94,7 @@ runtime·racefuncenter1(uintptr pc)
{ {
// If the caller PC is lessstack, use slower runtime·callers // If the caller PC is lessstack, use slower runtime·callers
// to walk across the stack split to find the real caller. // to walk across the stack split to find the real caller.
// Same thing if the PC is on the heap, which should be a if(pc == (uintptr)runtime·lessstack)
// closure trampoline.
if(pc == (uintptr)runtime·lessstack ||
(pc >= (uintptr)runtime·mheap->arena_start && pc < (uintptr)runtime·mheap->arena_used))
runtime·callers(2, &pc, 1); runtime·callers(2, &pc, 1);
m->racecall = true; m->racecall = true;
@ -162,8 +159,7 @@ memoryaccess(void *addr, uintptr callpc, uintptr pc, bool write)
m->racecall = true; m->racecall = true;
racectx = g->racectx; racectx = g->racectx;
if(callpc) { if(callpc) {
if(callpc == (uintptr)runtime·lessstack || if(callpc == (uintptr)runtime·lessstack)
(callpc >= (uintptr)runtime·mheap->arena_start && callpc < (uintptr)runtime·mheap->arena_used))
runtime·callers(3, &callpc, 1); runtime·callers(3, &callpc, 1);
runtimerace·FuncEnter(racectx, (void*)callpc); runtimerace·FuncEnter(racectx, (void*)callpc);
} }
@ -198,8 +194,7 @@ rangeaccess(void *addr, uintptr size, uintptr step, uintptr callpc, uintptr pc,
m->racecall = true; m->racecall = true;
racectx = g->racectx; racectx = g->racectx;
if(callpc) { if(callpc) {
if(callpc == (uintptr)runtime·lessstack || if(callpc == (uintptr)runtime·lessstack)
(callpc >= (uintptr)runtime·mheap->arena_start && callpc < (uintptr)runtime·mheap->arena_used))
runtime·callers(3, &callpc, 1); runtime·callers(3, &callpc, 1);
runtimerace·FuncEnter(racectx, (void*)callpc); runtimerace·FuncEnter(racectx, (void*)callpc);
} }

View File

@ -4,8 +4,11 @@
// +build race // +build race
TEXT runtime·racefuncenter(SB),7,$0 // func runtime·racefuncenter(pc uintptr)
PUSHQ DX // save function entry context (for closures) TEXT runtime·racefuncenter(SB), 7, $16
MOVQ DX, saved-8(SP) // save function entry context (for closures)
MOVQ pc+0(FP), DX
MOVQ DX, arg-16(SP)
CALL runtime·racefuncenter1(SB) CALL runtime·racefuncenter1(SB)
POPQ DX MOVQ saved-8(SP), DX
RET RET