| 1 |
// Copyright 2025 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a MIT |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
import ( |
| 8 |
"errors" |
| 9 |
"os" |
| 10 |
"runtime" |
| 11 |
"runtime/pprof" |
| 12 |
"sync" |
| 13 |
) |
| 14 |
|
| 15 |
func init() { |
| 16 |
register("Moby30408", Moby30408) |
| 17 |
} |
| 18 |
|
| 19 |
type Manifest_moby30408 struct { |
| 20 |
Implements []string |
| 21 |
} |
| 22 |
|
| 23 |
type Plugin_moby30408 struct { |
| 24 |
activateWait *sync.Cond |
| 25 |
activateErr error |
| 26 |
Manifest *Manifest_moby30408 |
| 27 |
} |
| 28 |
|
| 29 |
func (p *Plugin_moby30408) waitActive() error { |
| 30 |
p.activateWait.L.Lock() |
| 31 |
for !p.activated() { |
| 32 |
p.activateWait.Wait() |
| 33 |
} |
| 34 |
p.activateWait.L.Unlock() |
| 35 |
return p.activateErr |
| 36 |
} |
| 37 |
|
| 38 |
func (p *Plugin_moby30408) activated() bool { |
| 39 |
return p.Manifest != nil |
| 40 |
} |
| 41 |
|
| 42 |
func testActive_moby30408(p *Plugin_moby30408) { |
| 43 |
done := make(chan struct{}) |
| 44 |
go func() { // G2 |
| 45 |
p.waitActive() |
| 46 |
close(done) |
| 47 |
}() |
| 48 |
<-done |
| 49 |
} |
| 50 |
|
| 51 |
func Moby30408() { |
| 52 |
prof := pprof.Lookup("goroutineleak") |
| 53 |
defer func() { |
| 54 |
// Yield several times to allow the child goroutine to run. |
| 55 |
for i := 0; i < yieldCount; i++ { |
| 56 |
runtime.Gosched() |
| 57 |
} |
| 58 |
prof.WriteTo(os.Stdout, 2) |
| 59 |
}() |
| 60 |
|
| 61 |
go func() { // G1 |
| 62 |
p := &Plugin_moby30408{activateWait: sync.NewCond(&sync.Mutex{})} |
| 63 |
p.activateErr = errors.New("some junk happened") |
| 64 |
|
| 65 |
testActive_moby30408(p) |
| 66 |
}() |
| 67 |
} |