From: Roland Shoemaker Date: Thu, 18 Nov 2021 21:30:55 +0000 (-0800) Subject: internal/fuzz: compute correct number of mutations X-Git-Tag: go1.18beta1~240 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a94409660dbf05c1cdc2013aa2c7aa2489fe5c1c;p=gostls13.git internal/fuzz: compute correct number of mutations When reconstructing inputs, we miscalculated the number of mutations that needed to be applied. If the count%chainedMutation == 0 we would apply 0 mutations, when we should actually be applying chainedMutation mutations, due to how count is incremented. Fixes #49047 Change-Id: I76773bff0afd6dfd40deafc317be095da995ecc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/365294 Trust: Roland Shoemaker Trust: Katie Hockman Run-TryBot: Roland Shoemaker Run-TryBot: Katie Hockman Reviewed-by: Bryan C. Mills Reviewed-by: Katie Hockman TryBot-Result: Go Bot --- diff --git a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt index 5b1e26be24..3764dcb915 100644 --- a/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt +++ b/src/cmd/go/testdata/script/test_fuzz_mutator_repeat.txt @@ -1,5 +1,3 @@ -skip # https://golang.org/issue/49047 - # TODO(jayconrod): support shared memory on more platforms. [!darwin] [!linux] [!windows] skip diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go index e7d824bea1..5be49d28f9 100644 --- a/src/internal/fuzz/worker.go +++ b/src/internal/fuzz/worker.go @@ -1111,7 +1111,8 @@ func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzz wc.m.r.restore(mem.header().randState, mem.header().randInc) if !args.Warmup { // Only mutate the valuesOut if fuzzing actually occurred. - for i := int64(0); i < resp.Count%chainedMutations; i++ { + numMutations := ((resp.Count - 1) % chainedMutations) + 1 + for i := int64(0); i < numMutations; i++ { wc.m.mutate(valuesOut, cap(mem.valueRef())) } }