aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-10-06 11:54:41 -0400
committerRuss Cox <rsc@golang.org>2010-10-06 11:54:41 -0400
commit8599a8372713d51713c09771bb1d7bb6a4e600d2 (patch)
tree80d2a7c1289e4e2107da52578f61691b913d4eee
parent335a318c279deae521ac538bacd55098c4685875 (diff)
downloadgo-8599a8372713d51713c09771bb1d7bb6a4e600d2.tar.xz
runtime: correct iteration of large map values
The hash_next_and_deref was a dreg from a previous large value scheme. Fixes #1163. R=r, r2 CC=golang-dev https://golang.org/cl/2369043
-rw-r--r--src/pkg/runtime/hashmap.c15
-rw-r--r--test/fixedbugs/bug311.go20
2 files changed, 22 insertions, 13 deletions
diff --git a/src/pkg/runtime/hashmap.c b/src/pkg/runtime/hashmap.c
index eb98ab54aa..704196c2d2 100644
--- a/src/pkg/runtime/hashmap.c
+++ b/src/pkg/runtime/hashmap.c
@@ -920,17 +920,6 @@ void
}
}
-void*
-hash_next_and_deref(struct hash_iter *it)
-{
- void *p;
-
- p = hash_next(it);
- if(it->h->indirectval)
- p = *(void**)p;
- return p;
-}
-
// mapiterinit(hmap *map[any]any, hiter *any);
void
·mapiterinit(Hmap *h, struct hash_iter *it)
@@ -940,7 +929,7 @@ void
return;
}
hash_iter_init(h, it);
- it->data = hash_next_and_deref(it);
+ it->data = hash_next(it);
if(debug) {
prints("runtime.mapiterinit: map=");
·printpointer(h);
@@ -969,7 +958,7 @@ void
if(gcwaiting)
gosched();
- it->data = hash_next_and_deref(it);
+ it->data = hash_next(it);
if(debug) {
prints("runtime.mapiternext: iter=");
·printpointer(it);
diff --git a/test/fixedbugs/bug311.go b/test/fixedbugs/bug311.go
new file mode 100644
index 0000000000..ed937a6747
--- /dev/null
+++ b/test/fixedbugs/bug311.go
@@ -0,0 +1,20 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+// Copyright 2010 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+ m := make(map[string][1000]byte)
+ m["hi"] = [1000]byte{1}
+
+ v := m["hi"]
+
+ for k, vv := range m {
+ if k != "hi" || string(v[:]) != string(vv[:]) {
+ panic("bad iter")
+ }
+ }
+}