summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-02-06 14:41:21 -0800
committerRuss Cox <rsc@golang.org>2009-02-06 14:41:21 -0800
commit798b83b04b32fc522e79b099b0a4e69a01572f2a (patch)
tree9d52a1de28a6472fea4d94446cdb7d29f1646486 /src
parentdc7fbdc42800bac0642849a1f4aeaa1f2afc4361 (diff)
downloadgolang-798b83b04b32fc522e79b099b0a4e69a01572f2a.tar.gz
tgs's gc bug.
R=r DELTA=10 (7 added, 0 deleted, 3 changed) OCL=24577 CL=24577
Diffstat (limited to 'src')
-rw-r--r--src/runtime/malloc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/runtime/malloc.c b/src/runtime/malloc.c
index ac5de61a5..163ca8c73 100644
--- a/src/runtime/malloc.c
+++ b/src/runtime/malloc.c
@@ -121,8 +121,8 @@ free(void *v)
int32
mlookup(void *v, byte **base, uintptr *size, uint32 **ref)
{
- uintptr n, i;
- byte *p;
+ uintptr n, nobj, i;
+ byte *p, *ep;
MSpan *s;
s = MHeap_LookupMaybe(&mheap, (uintptr)v>>PageShift);
@@ -148,13 +148,20 @@ mlookup(void *v, byte **base, uintptr *size, uint32 **ref)
return 1;
}
+ if((byte*)v >= (byte*)s->gcref) {
+ // pointers into the gc ref counts
+ // do not count as pointers.
+ return 0;
+ }
+
n = class_to_size[s->sizeclass];
i = ((byte*)v - p)/n;
if(base)
*base = p + i*n;
if(size)
*size = n;
- if((byte*)s->gcref < p || (byte*)s->gcref >= p+(s->npages<<PageShift)) {
+ nobj = (s->npages << PageShift) / (n + RefcountOverhead);
+ if((byte*)s->gcref < p || (byte*)(s->gcref+nobj) > p+(s->npages<<PageShift)) {
printf("s->base sizeclass %d %p gcref %p block %D\n",
s->sizeclass, p, s->gcref, s->npages<<PageShift);
throw("bad gcref");