Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(178)

Side by Side Diff: src/pkg/runtime/gc_test.go

Issue 9831043: code review 9831043: runtime: fix heap corruption during GC (Closed)
Patch Set: diff -r e4db68a39f50 https://dvyukov%40google.com@code.google.com/p/go/ Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/runtime/mgc0.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « no previous file | src/pkg/runtime/mgc0.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b