-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
Fatal error: runtimer: bad p when resetting the value of a ticker pointer #45008
Comments
Smaller reproduction
|
I'm almost certain that |
Oh, yeah, I've had many iterations of this code. Also, not sure what the playground is running on, but I just tried it and it blows up there too: https://play.golang.org/p/SrcOyRpdncx |
why do you want to overwrite the destination of the ticker pointer with a copy of the results of NewTicker? Why doesn't ticker = time.NewTicker(timeout) work for you? |
Because I was originally passing the ticker into another function that had logic to determine if the ticker needed to be reset at a certain point. It was working locally so I didn't think anything of it, then it started crashing on staging and it took a while to track down that that was the issue. |
It already is: if you have a data race in your program, all bets are off. It's not unique to time.Ticker. |
Sorry, you can't use |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, tried this on 1.14, 1.15, and 1.16
What operating system and processor architecture are you using (
go env
)?Running on Ubuntu 20.04 kernel version 5.4.0-66-generic
Docker container running Debian 10
This was done using the base docker image golang:1.15
go env
OutputWhat did you do?
Dockerfile
test_timer.go
This is the simplest code I could build to reproduce the error. This code runs fine on my local machine (Ubuntu 20.04), but throws a
fatal error: runtimer: bad p
in the golang:1.15 docker container. It only happens if the code is built on the docker container. Building it locally then copying to the docker container doesn't trigger the issue, so it could be related to the version of shared libs on the distro. Addingapt upgrade -y
to the Dockerfile didn't help.It happens regardless of what kernel it's built on. Same thing happens on an amazon linux 2 ~4.14 machine.
I was doing
*ticker = *time.NewTicker(timeout)
instead ofticker = time.NewTicker(timeout)
because the reset was happening inside a function call. Workaround was to reorganize so that it returns the reset ticker instead. Go 1.15 also introduces theTicker.Reset
function so that can be used moving forward (the existing codebase is on 1.14), but wanted to report this issue in case it helps someone else who runs into a similar issue, or it's evidence of something else going on.What did you expect to see?
The program run and reset the ticker for the next iteration.
What did you see instead?
The text was updated successfully, but these errors were encountered: