Closed
Description
Describe the bug
There is a deadlock in signalReceivers.Stop:
syscall.SIGINT
is sent to the processShutdowner.Shutdown()
is called to stop the application- signalReceivers.Stop is called and takes the lock m
- signalReceivers.Stop sends a shutdown request (recv.shutdown <- struct{}{}) and blocks on the select
- In signalReceivers.relayer, the branch case signal := <-recv.signals: is executed before case <-recv.shutdown
- The branch case signal := <-recv.signals: calls signalReceivers.Broadcast
- signalReceivers.Broadcast takes the same lock
m
as signalReceivers.Stop
There is a deadlock.
To Reproduce
Run the following code:
func main() {
fx.New(fx.Invoke(func(shutdowner fx.Shutdowner) {
go func() {
_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
_ = shutdowner.Shutdown()
}()
})).Run()
}
Expected behavior
No deadlock
Metadata
Metadata
Assignees
Labels
No labels