Skip to content
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

internal/fuzz: improve readability of minimized string values #48657

Closed
ameowlia opened this issue Sep 27, 2021 · 3 comments
Closed

internal/fuzz: improve readability of minimized string values #48657

ameowlia opened this issue Sep 27, 2021 · 3 comments

Comments

@ameowlia
Copy link
Contributor

What version of Go are you using (go version)?

$ go version devel go1.18-abbfec2829b Thu Sep 23 11:10:56 2021 darwin/amd64

Does this issue reproduce with the latest release?

Yes, with the lastest gotip.

What operating system and processor architecture are you using (go env)?

go env Output
$ gotip env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/adowns/Library/Caches/go-build"
GOENV="/Users/adowns/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/adowns/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/adowns/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/adowns/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/adowns/sdk/gotip/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel go1.18-abbfec2829b Thu Sep 23 11:10:56 2021"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/adowns/workspace/go/src/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4c/1b3s36l94blb6xg1_4p_13800000gn/T/go-build4039734930=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I was playing around with the new fuzz testing. I ran this fuzzing test:

package length

import (
	"testing"
)

func Length(data string) int {
	if len(data) == 5 {
		panic("oh no! bad size!")
	}
	return len(data)
}

func FuzzLength(f *testing.F) {
	f.Add("meow")

	f.Fuzz(func(t *testing.T, a string) {
		want := len(a)
		len := Length(a)
		if len != want {
			t.Fatalf("Got: %q, Expected: %q", len, want)
		}
	})
}

What did you expect to see?

I expected to see string("00000") or some similar easy to read minimized crashing value. With go-fuzz this example would always return 00000.

What did you see instead?

Every time I re-ran it (deleting the testdata info before each run) I got different crashing values each time that were not very human friendly to read.

Here are some examples:

  • string("\xcf\xcf\xf1ou")
  • string("\u007f\u007f\xee\xee\xff")
  • string("oommw")
  • string("\x00\x1c\x17\x01\x80")

🌴 I hope you all are having a great quiet week!

@gopherbot
Copy link

Change https://golang.org/cl/352614 mentions this issue: internal/fuzz: minimize str to be human readable

@ALTree
Copy link
Member

ALTree commented Sep 28, 2021

Thanks for reporting the issue; but I think we're already tracking this in (the slightly more general) #48129.

I'm closing here as a duplicate; I suggest you test your patch on the testcases in #48129 too, and reference that issue (as Updates, or Fixes, depending on what it does on the test cases there).

@ALTree ALTree closed this as completed Sep 28, 2021
@ameowlia
Copy link
Contributor Author

🐱 Thank you @ALTree

@golang golang locked and limited conversation to collaborators Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants