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

Handle panic in Go routines #360

Open
sekulicd opened this issue Oct 25, 2024 · 1 comment · May be fixed by #362
Open

Handle panic in Go routines #360

sekulicd opened this issue Oct 25, 2024 · 1 comment · May be fixed by #362

Comments

@sekulicd
Copy link
Collaborator

While testing simulation PR i noticed that test fails for 5 users claiming in same round.
In logs i could see error "missing list of signed forfeit txs” in finalizeFound.
It was not obvious to find out root cause of this error as last log in startFinalization was "nonces collected for round”.
Was not able to figure it out how finalizeFound was invoked if startFinalization was not finished.
After some time by dumping go routines stack trace i saw that there was a panic in musig2.AggregateNonces which was ignored as there are no panic recovery for this go routine.
So code panicked, startFinalization exited and its defer func was called which continued with finalizeFound func invocation.

We have panic interceptor on server level but we need to handle panic in app service as this go routine is invoked before server is started.

func (s *service) start(withAppSvc bool) error {
	tlsConfig, err := s.config.tlsConfig()
	if err != nil {
		return err
	}

	if err := s.newServer(tlsConfig, withAppSvc); err != nil {
		return err
	}

	if withAppSvc {
		appSvc, _ := s.appConfig.AppService()
		if err := appSvc.Start(); err != nil {
			return fmt.Errorf("failed to start app service: %s", err)
		}
		log.Info("started app service")
	}

	if s.config.insecure() {
		// nolint:all
		go s.server.ListenAndServe()
	} else {
		// nolint:all
		go s.server.ListenAndServeTLS("", "")
	}
	log.Infof("started listening at %s", s.config.address())

	return nil
}

Check as well in SDK or elsewhere if there are go routines without panic recovery.

@sekulicd
Copy link
Collaborator Author

sekulicd commented Oct 25, 2024

PS. Its complete mystery to me why app doesnt crash, looks like bug in runtime pkg.

@sekulicd sekulicd linked a pull request Oct 28, 2024 that will close this issue
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