-
Notifications
You must be signed in to change notification settings - Fork 18k
time: racy Timer access should either work or throw, not panic #37400
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
Comments
Could this be related to #37196? (I'm not sure.) |
The panic inside time.Timer.Stop should really be runtime.throw. Code does not expect panic from Stop. If there's really a racy use of timers and timers are corrupt, stop executing. |
Also, time.stopTimer clearly called deltimer, and deltimer called badTimer, which panicked. Do we not have a stack frame for deltimer showing what line it is at? Do we not have a stack frame for badTimer? Why not? |
That may be #26206..? |
This program crashes very quickly:
I don't believe this program should panic. The claim in the runtime code is that the runtime timer data structures may be corrupted, but if so then there is not enough locking protecting against bad user call sequences. But the bad user call sequences should find a way to complete (serialize them somehow), no? |
Seems like a possible Go 1.14 release blocker. |
/cc @aclements |
I can reproduce this with go1.14rc1, go1.14beta1, but also with go1.13.7 on darwin/amd64:
|
This also seems to reproduce on go1.12.17, although less reliably:
|
This issue is blocking the Go 1.14 release, which is currently underway (but has not been cut yet, so we can still safely abort it or make changes if necessary). See #37445 (comment). |
This panic was introduced in Go 1.11, so I guess it is not a Go 1.14 release blocker. Still think it should probably either be fixed or changed to a runtime.throw. The unexpected panic is problematic (see the nested panic in the trace above). Stop should either work or crash the program, not panic. |
I filed details about the net/http timer usage in #37449. The code, from 2016, is aware of the fact that Reset and Stop are racing and handled either ordering correctly. What it did not expect is the panic introduced in Go 1.11. If we decide that this panic is important to keep, we will need to rewrite that code in http2. |
Just to be clear, the problem was not introduced in 1.11. The program above also fails with 1.10. Before 1.10 the problem still exists but is harder to reproduce. What changed in 1.10 was that we switched to many different timer buckets. With fewer timers in each bucket it's easier to create a case in which In any case we can do better with the new timers. |
Change https://golang.org/cl/221077 mentions this issue: |
We started to get panics right after updating to Go 1.14.
|
@gopherbot Please open a backport to 1.14. |
Backport issue(s) opened: #37494 (for 1.14). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/221298 mentions this issue: |
Hello @makhov, would you be interested in confirming it is fixed for you by trying with tip? Using tip via https://godoc.org/golang.org/dl/gotip is very convenient, or you could directly compile from source if you prefer. |
@thepudds Thanks! I'll try it in a canary. Panics happen no such often, so I'll keep it running for the weekend. |
If we see a racy use of timers, as in concurrent calls to Timer.Reset, do the operations in an unpredictable order, rather than crashing. Updates #37400 Updates #37449 Fixes #37494 Change-Id: Idbac295df2dfd551b6d762909d5040fc532c1b34 Reviewed-on: https://go-review.googlesource.com/c/go/+/221077 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> (cherry picked from commit 98858c4) Reviewed-on: https://go-review.googlesource.com/c/go/+/221298
@thepudds The panic seems to be fixed. Thanks! |
2020-02-21T20:22:19-13d73b2/linux-arm
CC @ianlancetaylor @bradfitz @tombergan
The text was updated successfully, but these errors were encountered: