-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/big, go/constant: fuzz with go-fuzz #20234
Comments
In Go tree I found a few fuzz tests using |
I wrote some go-fuzz test for std lib at: |
We've had a couple issues with math/big assembly code routines (e.g., #31084, #42838), so it's probably worth revisiting this issue and seeing if we can get some basic fuzzing tests implemented. There's a rather minimal set of low-level arithmetic routines to worry about (https://github.com/golang/go/blob/master/src/math/big/arith_decl.go), and they all have known-good reference implementations that can be easily compared against. |
I think the tricky part here is getting full coverage of the assembly routines. Can the fuzzer fuzz assembly? Getting full coverage on the reference Go implementation is a good start, but might miss some paths through the assembly. |
I was thinking as a start just randomly/exhaustively generating inputs (e.g., random word values, but probably exhaustive shift values from 0 through 63), feeding them through both the reference and assembly implementations, and making sure they produce identical outputs. Edit: I'm suggesting we just write some manual differential fuzzers as regular Go tests. Using go-fuzz or something would be nice, but I don't think it's necessary. |
Here's a very basic differential test that would have found the s390x bug:
I tried running it on a handful of other arches available through gomote (arm, arm64, ppc64le, mips64le) and didn't find any other failures except s390x's shl implementation. |
@mdempsky could you please send a change to https://github.com/google/oss-fuzz/blob/master/projects/golang/math_big_fuzzer.go or another file with the appropriate build tags/guards? Thank you |
@odeke-em Sorry, this hasn't been a priority for me. I welcome if anyone else wants to submit extra tests along the lines that I described though. |
go-fuzz found a few math/big and go/constant bugs indirectly, via go/types and cmd/compile:
#20227
#20228
That's a pretty inefficient way to find them, though. We should run it on them directly and flush out a few more.
@ALTree @dvyukov
The text was updated successfully, but these errors were encountered: