diff --git a/fuzz/worker.go b/fuzz/worker.go index c3f4d74..d8cc10d 100644 --- a/fuzz/worker.go +++ b/fuzz/worker.go @@ -632,6 +632,9 @@ func (ws *workerServer) fuzz(ctx context.Context, args fuzzArgs) (resp fuzzRespo resp.Count = mem.header().count ws.memMu <- mem }() + if args.Limit > 0 && mem.header().count >= args.Limit { + panic(fmt.Sprintf("mem.header().count %d already exceeds args.Limit %d", mem.header().count, args.Limit)) + } vals, err := unmarshalCorpusFile(mem.valueCopy()) if err != nil { diff --git a/fuzz/worker_test.go b/fuzz/worker_test.go index 10d61b1..b536b3d 100644 --- a/fuzz/worker_test.go +++ b/fuzz/worker_test.go @@ -25,6 +25,11 @@ func BenchmarkWorkerFuzzOverhead(b *testing.B) { if err != nil { b.Fatalf("failed to create temporary shared memory file: %s", err) } + defer func() { + if err := mem.Close(); err != nil { + b.Error(err) + } + }() initialVal := []interface{}{make([]byte, 32)} encodedVals := marshalCorpusFile(initialVal...) @@ -36,6 +41,7 @@ func BenchmarkWorkerFuzzOverhead(b *testing.B) { for i := 0; i < b.N; i++ { ws.m = newMutator() mem.setValue(encodedVals) + mem.header().count = 0 ws.fuzz(context.Background(), fuzzArgs{Limit: 1}) }