-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Closed
Labels
area/loggingexp/beginnerhelp wantedkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
Description
Description
When the newRingLogger is created.
moby/daemon/logger/ring_test.go
Lines 25 to 28 in 37f8662
| func TestRingLogger(t *testing.T) { | |
| mockLog := &mockLogger{make(chan *Message)} // no buffer on this channel | |
| ring := newRingLogger(mockLog, Info{}, 1) | |
| defer ring.setClosed() |
The
defer ring.Close() method should be called to awaken the cond.Wait().Lines 192 to 194 in 37f8662
| for len(r.queue) == 0 && !r.closed { | |
| r.wait.Wait() | |
| } |
However, the actual method invoked is
defer ring.setClosed(), which doesn't invoke r.wait.Broadcast(), resulting in goroutine leak.
Reproduce
You could use goleak to reproduce the bug in the function as follows.
moby/daemon/logger/ring_test.go
Line 25 in 37f8662
| func TestRingLogger(t *testing.T) { |
func TestRingLogger(t *testing.T) {
defer goleak.VerifyNone(t)
xxx
}
The result is similar to this:
Expected behavior
How to fix the bug:
invoking defer ring.Close() instead of defer ring.setClosed() in the function.
docker version
latestdocker info
-Additional Info
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/loggingexp/beginnerhelp wantedkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed.
