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

go-fuzz-build fails when 'fmt' is not imported #157

Closed
jscrockett01 opened this issue Feb 27, 2017 · 0 comments
Closed

go-fuzz-build fails when 'fmt' is not imported #157

jscrockett01 opened this issue Feb 27, 2017 · 0 comments

Comments

@jscrockett01
Copy link

I stumbled across this bug and workaround. When running go-fuzz-build against a package that does not import "fmt" I get the following error:

code:

package fuzz

func Fuzz(buf []byte) int {
	switch len(buf) {
	case 5:
		panic("crash")
	case 7:
		return 1
	}
	return 0
}

error:

failed to execute go build: exit status 1
C:\Users\Crockett\AppData\Local\Temp\go-fuzz-build377837498\goroot\src\time\zoneinfo_windows.go:9:2: cannot find package "internal/syscall/windows/registry" in any of:
        C:\Users\Crockett\AppData\Local\Temp\go-fuzz-build377837498\goroot\src\internal\syscall\windows\registry (from $GOROOT)
        C:\Users\Crockett\AppData\Local\Temp\go-fuzz-build377837498\gopath\src\internal\syscall\windows\registry (from $GOPATH)
C:\Users\Crockett\AppData\Local\Temp\go-fuzz-build377837498\goroot\src\syscall\dll_windows.go:8:2: cannot find package "internal/syscall/windows/sysdll" in any of:
        C:\Users\Crockett\AppData\Local\Temp\go-fuzz-build377837498\goroot\src\internal\syscall\windows\sysdll (from $GOROOT)
        C:\Users\Crockett\AppData\Local\Temp\go-fuzz-build377837498\gopath\src\internal\syscall\windows\sysdll (from $GOPATH)

However, when I add a dummy import of 'fmt' the error disappears and fuzzing works fine:

package fuzz

import "fmt"

var _ = fmt.Print

func Fuzz(buf []byte) int {
	switch len(buf) {
	case 5:
		panic("crash")
	case 7:
		return 1
	}
	return 0
}
AlekSi pushed a commit to AlekSi/go-fuzz that referenced this issue Feb 6, 2018
Currently we have hardcoded list of go-fuzz-dep dependencies.
This list constantly changes due to changes in std lib
(due various new internal packages).
Extract go-fuzz-dep dependencies automatically with 'go list'.

Fixes dvyukov#157
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant