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
strconv: permit values other than 32 and 64 in ParseFloat; add a vet check for those values #42297
Comments
I at least have all the source code in a single file reproducer at https://github.com/mark-rushakoff/goissue42297, but it is a nearly 3000 line file. I should be able to get it trimmed down quite a bit. |
What is happening here is that you are passing Since it has always been documented as accepting only |
I see it now -- our code was masking the error that reported Thanks for quickly identifying what was wrong there and for fixing the issue title. |
@ianlancetaylor I agree, this just makes incorrect code panic (did you mean 32 or 64?) and is already documented, so just a release notes change seems fine. I can create a CL with a small addition to https://github.com/golang/go/blob/master/doc/go1.16.html in the next few days. |
Hmm, actually ... I've done some searching to see how common this is, and it seems like a fairly common mistake to use 10 (presumably because the second argument to
It would be a bit different if I think there are two possibilities here:
I guess I lean towards option 1, as it's "safest". The Go 1 Compatibility Promise is strong with that one. Thoughts? P. S. Vaguely relevant: https://xkcd.com/1172/ |
I'm OK with accepting values other than 64, in which case we should have a test or two for that. |
With that many occurrences, we could also add take the approach of adding a vet check now, and then consider changing the code in a future release, and then in a still later release removing the vet check. |
Sounds good. I'll upload a change that reverts the "error on invalid bitSize" behavior, and then look into adding a simple vet check (that might be kind of fun -- do you have any pointers or recent commits on adding a new vet check?) |
Change https://golang.org/cl/267319 mentions this issue: |
@ianlancetaylor Change submitted for reverting the bitSize invalid error (and added tests for this): https://go-review.googlesource.com/c/go/+/267319 ... I intend to submit a change for the vet check later. |
Oh also: you may want to update this issue title to reflect what we're actually doing. |
This is a partial revert of https://go-review.googlesource.com/c/go/+/248219 because we found that a non-trivial amount of code erroneously calls ParseFloat(s, 10) or even ParseFloat(s, 0) and expects it to work -- before that change was merged, ParseFloat accepted a bitSize of anything other than 32 or 64 to mean 64 (and ParseComplex was similar). So revert that behavior to avoid breaking people's code, and add tests for this. I may add a vet check to flag ParseFloat(s, not_32_or_64) in a later change. See #42297 for more details. Change-Id: I4bc0156bd74f67a39d5561b6e5fde3f2d20bd622 Reviewed-on: https://go-review.googlesource.com/c/go/+/267319 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/267600 mentions this issue: |
@ianlancetaylor
|
@benhoyt Those are good questions. Can you open a new issue just for the vet check? Thanks. |
Sure. Done: #42389 |
Per discussion at #42389, we've decided not to add any vet check. While ParseFloat(s, 10) is incorrect and strictly speaking a mistake, it's probably not going to cause issues or be a bug. |
Oh, I guess I can't close this issue. @mark-rushakoff or @ianlancetaylor can you please close this now, seeing we've addressed the "permit other values" part and decided against the vet check. |
Thanks for your work on this. |
Does this issue reproduce with the latest release?
I have a unit test that has been passing for quite some time. It fails with
go version devel +60f42ea61c Fri Oct 30 00:13:25 2020 +0000 darwin/amd64
but passes withgo version devel +01efc9a3c5 Fri Oct 30 00:03:40 2020 +0000 darwin/amd64
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Check out github.com/influxdata/influxdb at commit f6a26ee2b99c1225cf1ca09487ea8fb45e515860 (approximately master at the time of writing this issue). Run
go test ./models
.It was passing with go tip yesterday, but it is failing with go tip at
go version devel +256d729c0b Fri Oct 30 15:26:28 2020 +0000 darwin/amd64
.What did you expect to see?
What did you see instead?
Here is my git bisect log from the go repo:
I don't yet have a minimal test case, but I may find some time today to reduce it. I'm filing the issue now in case anything jumps out to anyone else.
/cc @griesemer @minux @benhoyt for commit 60f42ea
The text was updated successfully, but these errors were encountered: