OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package runtime_test | 5 package runtime_test |
6 | 6 |
7 import ( | 7 import ( |
8 "os" | 8 "os" |
9 "runtime" | 9 "runtime" |
10 "runtime/debug" | 10 "runtime/debug" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 head = p | 115 head = p |
116 runtime.GC() | 116 runtime.GC() |
117 } | 117 } |
118 for p := head; p != nil; p = p.next { | 118 for p := head; p != nil; p = p.next { |
119 if p.buf[0] != 42 { | 119 if p.buf[0] != 42 { |
120 t.Fatal("corrupted heap") | 120 t.Fatal("corrupted heap") |
121 } | 121 } |
122 } | 122 } |
123 } | 123 } |
| 124 |
| 125 func TestGcRescan(t *testing.T) { |
| 126 type X struct { |
| 127 c chan error |
| 128 nextx *X |
| 129 } |
| 130 type Y struct { |
| 131 X |
| 132 nexty *Y |
| 133 p *int |
| 134 } |
| 135 var head *Y |
| 136 for i := 0; i < 10; i++ { |
| 137 p := &Y{} |
| 138 p.c = make(chan error) |
| 139 p.nextx = &head.X |
| 140 p.nexty = head |
| 141 p.p = new(int) |
| 142 *p.p = 42 |
| 143 head = p |
| 144 runtime.GC() |
| 145 } |
| 146 for p := head; p != nil; p = p.nexty { |
| 147 if *p.p != 42 { |
| 148 t.Fatal("corrupted heap") |
| 149 } |
| 150 } |
| 151 } |
OLD | NEW |