Skip to content

goroutines leak in Reauthenticate #1977

@pamburus

Description

@pamburus

Following code in provider_client.go does not work as described:

	// Report result to all other interested goroutines.
	//
	// This happens in a separate goroutine because another goroutine might have
	// acquired a copy of `client.reauthmut.ongoing` before we cleared it, but not
	// have come around to sending its request. By answering in a goroutine, we
	// can have that goroutine linger until all responseChannels have been sent.
	// When GC has collected all sendings ends of the channel, our receiving end
	// will be closed and the goroutine will end.
	go func() {
		for responseChannel := range messages {
			responseChannel <- err
		}
	}()

Garbage collector does not collect such goroutines and they leak.

Here is a simple example which proves that:
https://play.golang.org/p/99jyHd9R_AX

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions