We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f1b12b commit afb5fcaCopy full SHA for afb5fca
test/fixedbugs/issue24491b.go
@@ -11,33 +11,33 @@ package main
11
12
import (
13
"runtime"
14
- "sync/atomic"
15
"unsafe"
16
)
17
18
-var done uint32
+var done = make(chan bool)
19
20
func setup() unsafe.Pointer {
21
s := "ok"
22
- runtime.SetFinalizer(&s, func(p *string) { atomic.StoreUint32(&done, 1) })
+ runtime.SetFinalizer(&s, func(p *string) { close(done) })
23
return unsafe.Pointer(&s)
24
}
25
26
//go:noinline
27
//go:uintptrescapes
28
func before(p uintptr) int {
29
runtime.GC()
30
- if atomic.LoadUint32(&done) != 0 {
+ select {
+ case <-done:
31
panic("GC early")
32
+ default:
33
34
return 0
35
36
37
func after() int {
38
- if atomic.LoadUint32(&done) == 0 {
39
- panic("GC late")
40
- }
+ runtime.GC()
+ <-done
41
42
43
0 commit comments