[Bug]:A potential goroutine leak
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- go
- Domain
- operating-systems
Research direction
Start at fifo.go lines 124-133 and compare the behavior with fifo_test.go around line 47. Run the supplied TestFifoNocancel reproduction with goleak and inspect how OpenFifo behaves with context.Background(), O_RDONLY|O_CREAT|O_NONBLOCK. Done means the reproduction no longer reports a goroutine leak while the existing FIFO tests still pass.
Written by the indexing model from the issue text.
Description
Hello @samuelkarp, When I used fifo, I found a potential bug, I'm not sure, maybe we can discuss to avoid a goleak
blocking position:
https://github.com/containerd/fifo/blob/3e17f98903a83f1a6c7368ea4694e6861161d6bd/fifo.go#L124-L133
if users use the OpenFilo() with the parameters like this:
f, err := OpenFifo(context.Background(), filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
The select statement will block beacuse there is no cancelFunc to awaken the <-ctx.Done().
I wrote a test function to reproduce the bug considering the test that https://github.com/containerd/fifo/blob/3e17f98903a83f1a6c7368ea4694e6861161d6bd/fifo_test.go#L47
func TestFifoNocancel(t *testing.T) {
defer goleak.VerifyNone(t)
tmpdir, err := os.MkdirTemp("", "fifos")
assert.NoError(t, err)
defer os.RemoveAll(tmpdir)
leakCheckWg = &sync.WaitGroup{}
defer func() {
leakCheckWg = nil
}()
//f, err := OpenFifo(context.Background(), filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_NONBLOCK, 0600)
f, err := OpenFifo(context.Background(), filepath.Join(tmpdir, "f0"), syscall.O_RDONLY|syscall.O_CREAT|syscall.O_NONBLOCK, 0600)
assert.Exactly(t, nil, f)
assert.NotNil(t, err)
assert.NoError(t, checkWgDone(leakCheckWg))
}
The test result shows it is a goroutine leak, you can use goleak to reproduce the bug.
- Dominant language
- Go
- Stars
- 87
- Forks
- 33
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from containerd/fifo
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
containerd/fifo#67 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
containerd/fifo#43 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
containerd/fifo#18 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
containerd/fifo#5 · 1 comment ·
Similar issues
-
P3 tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
kind/feature needs-triage priority/unprioritized
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NVIDIA/k8s-test-infra#1504 ·
Maintainers usually reply within 1 day
-
Area/Infrastructure Aspect/Infra Resources Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
wso2/agent-manager#2717 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
open-policy-agent/opa#9685 · 1 comment ·
Maintainers usually reply within 1 day