runtime: fix data/bss shadow memory mapping for race detector

Fixes #5175.
Race detector runtime expects values passed to MapShadow() to be page-aligned,
because they are used in mmap() call. If they are not aligned mmap() trims
either beginning or end of the mapping.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8325043
This commit is contained in:
Dmitriy Vyukov 2013-04-04 09:11:34 +11:00 committed by Andrew Gerrand
parent e798cd857c
commit 12b7db3d57

View File

@ -36,11 +36,14 @@ static bool onstack(uintptr argp);
uintptr
runtime·raceinit(void)
{
uintptr racectx;
uintptr racectx, start, size;
m->racecall = true;
runtimerace·Initialize(&racectx);
runtimerace·MapShadow(noptrdata, enoptrbss - noptrdata);
// Round data segment to page boundaries, because it's used in mmap().
start = (uintptr)noptrdata & ~(PageSize-1);
size = ROUND((uintptr)enoptrbss - start, PageSize);
runtimerace·MapShadow((void*)start, size);
m->racecall = false;
return racectx;
}