pkg icon indicating copy to clipboard operation
pkg copied to clipboard

fix: possible goroutine leak in exec

Open noxiouz opened this issue 1 year ago • 2 comments

If timeout happens and ShouldWait is false (default) cmd.Wait() goroutine will stack forever on sending to done channel. The will be no receiver from done. Making the channel buffered lets the goroutine exit.

noxiouz avatar Jul 08 '23 22:07 noxiouz

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

sonarqubecloud[bot] avatar Jul 11 '23 11:07 sonarqubecloud[bot]

In the old version of the package:

oroutine 1482 [chan send, 47 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 2141 [chan send, 20 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 1924 [chan send, 29 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 1379 [chan send, 51 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 1921 [chan send, 29 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 1432 [chan send, 49 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 2341 [chan send, 12 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

goroutine 1369 [chan send, 51 minutes]:
github.com/argoproj/pkg/exec.RunCommandExt.func1()
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x3f
created by github.com/argoproj/pkg/exec.RunCommandExt
	/go/pkg/mod/github.com/argoproj/[email protected]/exec/exec.go:94 +0x43f

But the bug is relevant for the latest version too

noxiouz avatar Jul 13 '23 23:07 noxiouz