Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: unbuffered signal channel could cause signal not to be delivered #6

Closed
odeke-em opened this issue Dec 1, 2020 · 0 comments · Fixed by #7
Closed

server: unbuffered signal channel could cause signal not to be delivered #6

odeke-em opened this issue Dec 1, 2020 · 0 comments · Fixed by #7

Comments

@odeke-em
Copy link

odeke-em commented Dec 1, 2020

Coming here from auditing

keyrace/server.go

Lines 281 to 283 in dab1b87

signals := make(chan os.Signal)
signal.Notify(signals, os.Interrupt)
signal.Notify(signals, syscall.SIGTERM)

which is a bug as documented in os/signal https://golang.org/pkg/os/signal/#Notify as per:
Screen Shot 2020-11-30 at 9 15 04 PM

For Go1.17, my team is going to release a static analyzer that'll be included when you run go test as per golang/go#9399, but for now, please make that channel buffered.

Our internal static analyzer reports this:

$ sigchanyzer ./server.go 
github.com/nat/keyrace/server.go:282:2: misuse of unbuffered os.Signal channel as argument to signal.Notify

/cc @cuonglm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant