Debian Codegraph @

src/runtime/testdata/testgoroutineleakprofile/goker/moby17176.go

raw
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 /*
6 * Project: moby
7 * Issue or PR : https://github.com/moby/moby/pull/17176
8 * Buggy version: d295dc66521e2734390473ec1f1da8a73ad3288a
9 * fix commit-id: 2f16895ee94848e2d8ad72bc01968b4c88d84cb8
10 * Flaky: 100/100
11 */
12 package main
13
14 import (
15 "errors"
16 "os"
17 "runtime/pprof"
18 "sync"
19 "time"
20 )
21
22 func init() {
23 register("Moby17176", Moby17176)
24 }
25
26 type DeviceSet_moby17176 struct {
27 sync.Mutex
28 nrDeletedDevices int
29 }
30
31 func (devices *DeviceSet_moby17176) cleanupDeletedDevices() error {
32 devices.Lock()
33 if devices.nrDeletedDevices == 0 {
34 /// Missing devices.Unlock()
35 return nil
36 }
37 devices.Unlock()
38 return errors.New("Error")
39 }
40
41 func testDevmapperLockReleasedDeviceDeletion_moby17176() {
42 ds := &DeviceSet_moby17176{
43 nrDeletedDevices: 0,
44 }
45 ds.cleanupDeletedDevices()
46 doneChan := make(chan bool)
47 go func() {
48 ds.Lock()
49 defer ds.Unlock()
50 doneChan <- true
51 }()
52
53 select {
54 case <-time.After(time.Millisecond):
55 case <-doneChan:
56 }
57 }
58 func Moby17176() {
59 prof := pprof.Lookup("goroutineleak")
60 defer func() {
61 time.Sleep(100 * time.Millisecond)
62 prof.WriteTo(os.Stdout, 2)
63 }()
64
65 for i := 0; i < 100; i++ {
66 go testDevmapperLockReleasedDeviceDeletion_moby17176()
67 }
68 }