gotesting

When I run `go test -fuzz=Fuzz`, Not enough memory resources are available to process this command


When I was doing fuzz testing in Go according to the examples in the documentation, I got this error.

error log

$ go test -fuzz=Fuzz warning: the test binary was not built with coverage instrumentation, so fuzzing will run without coverage guidance and may be inefficient --- FAIL: FuzzReverse (0.01s) mapping temporary file C:\Users\use\AppData\Local\Temp\fuzz-2637883721: Not enough memory resources are available to process this command. FAIL exit status 1 FAIL example/fuzz 0.031s

my code

package main

import (
    "testing"
    "unicode/utf8"
)

func FuzzReverse(f *testing.F) {
    testcases := []string{"Hello, world", " ", "!12345"}
    for _, tc := range testcases {
        f.Add(tc) // Use f.Add to provide a seed corpus
    }
    f.Fuzz(func(t *testing.T, orig string) {
        rev := Reverse(orig)
        doubleRev := Reverse(rev)
        if orig != doubleRev {
            t.Errorf("Before: %q, after: %q", orig, doubleRev)
        }
        if utf8.ValidString(orig) && !utf8.ValidString(rev) {
            t.Errorf("Reverse produced invalid UTF-8 string %q", rev)
        }
    })
}

and test log

$ go test
PASS ok example/fuzz 0.027s

$ go version go version go1.23.0 windows/386


Solution

  • Sorry, I downloaded and used go version go1.23.0 windows/386 by mistake. I used echo %PROCESSOR_ARCHITECTURE% to check my CPU architecture as amd64. After I reinstalled the go language for amd64 and checked go env, my fuzzy query no longer reported this error. And it is consistent with the document results. Very important sentence: Go fuzzing with coverage instrumentation is only available on AMD64 and ARM64 architectures currently.