-
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
math/rand: panic generating NormFloat64 #66086
Comments
Looking at the code: Lines 239 to 249 in 6f5d774
This bug looks impossible. Because rng.tap and rng.feed are always updated with -- and += rngLen adds 603 if it is negative, so the index can't be -1 (as if it were += 603 would make it 602 ).Is this function called concurrently ? What does running your code with -race says ?
|
Yes, we are calling rand.NormFloat64() using different go routines so it is called concurrently, we didn't try to run it with -race this was a rare case and wouldn't reproduce easily, just thought of reporting this in case it was not reported earlier. our repo is open source this is the file: https://github.com/lavanet/lava/blob/main/protocol/provideroptimizer/provider_optimizer.go and full log of the panic:
|
You should try |
ok an update here this happens quite frequently, I would hope it would get fixed. for now we will just use some other methodology |
what happens frequently ? The race ? |
yes, we are using this method when traffic enters our servers, when the load increased this happens every few seconds. crashing our server. |
There is this mention at the top of
I'm closing this as wontfix if that a confirmed race as you are improperly using a non thread safe object concurrently. |
Go version
go 1.20.5
Output of
go env
in your module/workspace:What did you do?
firstly we generate a global random instance:
And later on we are running:
generating the float caused our application to panic, Important to note this is very rare we used this method probably millions of times before it crashed.
What did you see happen?
What did you expect to see?
Getting a random float without a panic :)
The text was updated successfully, but these errors were encountered: