Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/goPublic

Commitff7cb87

Browse files
committed
[release-branch.go1.1] runtime: zeroize g->fnstart to not prevent GC of the closure
««« CL 9557043 / 2c128d417029runtime: zeroize g->fnstart to not prevent GC of the closureFixes#5493.R=golang-dev, minux.ma, iantCC=golang-devhttps://golang.org/cl/9557043»»»R=dvyukov, iant, minux.ma, bradfitz, daveCC=golang-devhttps://golang.org/cl/10031043
1 parentb9b37d1 commitff7cb87

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

‎src/pkg/runtime/proc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,7 @@ static void
12321232
goexit0(G*gp)
12331233
{
12341234
gp->status=Gdead;
1235+
gp->fnstart=nil;
12351236
gp->m=nil;
12361237
gp->lockedm=nil;
12371238
m->curg=nil;

‎test/fixedbugs/issue5493.go‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// run
2+
3+
// Copyright 2013 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package main
8+
9+
import (
10+
"runtime"
11+
"sync"
12+
"sync/atomic"
13+
"time"
14+
)
15+
16+
constN=10
17+
varcountint64
18+
19+
funcrun()error {
20+
f1:=func() {}
21+
f2:=func() {
22+
func() {
23+
f1()
24+
}()
25+
}
26+
runtime.SetFinalizer(&f1,func(f*func()) {
27+
atomic.AddInt64(&count,-1)
28+
})
29+
gof2()
30+
returnnil
31+
}
32+
33+
funcmain() {
34+
count=N
35+
varwg sync.WaitGroup
36+
wg.Add(N)
37+
fori:=0;i<N;i++ {
38+
gofunc() {
39+
run()
40+
wg.Done()
41+
}()
42+
}
43+
wg.Wait()
44+
fori:=0;i<2*N;i++ {
45+
time.Sleep(10*time.Millisecond)
46+
runtime.GC()
47+
}
48+
ifcount!=0 {
49+
panic("not all finalizers are called")
50+
}
51+
}
52+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp