-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
database/sql: sync.Mutex unlocked when panic cause by context #54110
Comments
Why or how should |
ctx.Done() should not panic normally,but it may panic unexpected. And ctx may unexpectly be nil, it makes the same result. |
Don't pass a nil context. Go code doesn't try to handle every conceivable panic. This program has a logic error which should be caught by ordinary testing, and there is no need for the standard library to handle this case. Sorry. |
quite agree that. and I think the code now could be fixed to avoid hang-up when panic happened. As the PR #54144 does,it does not handle the panic caused by context ,but it avoid locker be unlocked,and make it running on right way. |
Change https://go.dev/cl/420074 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
// with nil context.Context
tx, err := db.BeginTx(nil, nil)
if err != nil {
return err
}
defer tx.Commit()
panic happend in conn and it makes locker not be unlocked
The text was updated successfully, but these errors were encountered: