go-fuzz: go-fuzz-build doesn't work with go modules (go 1.11.2)

FTR: I’m going to investigate this issue a bit. If the problem is on my side, I will close the issue.

Environment:

> go version
go version go1.11.2 darwin/amd64

> go env GOROOT GOPATH
/usr/local/Cellar/go/1.11.2/libexec
/Users/asd/go

Steps to reproduce inside GOPATH:

> pwd
/Users/asd/go/src/github.com/sashka/signedvalue

> go-fuzz-build github.com/sashka/signedvalue
failed to execute go build: exit status 1
go: finding github.com/dvyukov/go-fuzz v0.0.0-20181106053552-383a81f6d048
go: finding github.com/stephens2424/writerset v0.0.0-20150719204953-fe01f9c9e73f
go: finding github.com/elazarl/go-bindata-assetfs v1.0.0
go: finding github.com/sashka/signedvalue/go.fuzz.main latest
can't load package: package github.com/sashka/signedvalue/go.fuzz.main: unknown import path "github.com/sashka/signedvalue/go.fuzz.main": cannot find module providing package github.com/sashka/signedvalue/go.fuzz.main

Steps to reproduce outside GOPATH:

> cd /tmp
> git clone git@github.com:sashka/signedvalue
Cloning into 'signedvalue'...
...
> cd signedvalue/
> go-fuzz-build github.com/sashka/signedvalue
package dir 'go: finding github.com/dvyukov/go-fuzz/go-fuzz-dep latest
go: finding github.com/dvyukov/go-fuzz latest
/Users/asd/go/pkg/mod/github.com/dvyukov/go-fuzz@v0.0.0-20181106053552-383a81f6d048/go-fuzz-dep' does not end with import path 'github.com/dvyukov/go-fuzz/go-fuzz-dep'

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 26 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I’m pretty sure @josharian has a master plan here, I just don’t know if he’s made it public 😃

Anyone is free to copy what I did here: https://github.com/mvdan/sh/tree/master/_fuzz/it

The steps are:

  • create a nested module that depends on the main module via a replace (see go.mod), and that contains fuzz.go
  • use a script to create a GOPATH with all necessary packages; see fuzz-gopath, this is possible with a few lines thanks to go mod vendor
  • run go-fuzz-build with the GOPATH set up above (and modules turned off); see fuzz-ci

As a bonus point, you can also track/pin the version of go-fuzz-build via go.mod; see tools.go. This system takes a bit of setup, but it works well for me.

OK. Reopened.

go-fuzz-build still does not work with go modules. Can you consider reopening the issue please ?

Hey @thepudds, sure, I can add a friendly ping. In the meantime I suggest https://github.com/dvyukov/go-fuzz/pull/271 to remove pressure and give the users that are blocked by this feature to opt-in.

@thepudds maybe we can do some incremental addition of this feature. i.e by adding some flag that enable this support until google/oss-fuzz#2878 is solved?

We’ll see how things end up, but most likely https://github.com/google/oss-fuzz/issues/2878 needs to land first before landing modules support in go-fuzz. (https://github.com/google/oss-fuzz/issues/2878 is a hopefully a small change).

I would like to work (me or some one from my team) on this issue.

Great!

But before jumping and implementing I wanted to understand how complicated this is and how it should be implemented in terms of the design? we can come up with a proposal as well but wanted to see if there is already an idea in mind?

A short proposal is a fine way to proceed. It is possible that to understand enough to write a proposal you will find you need to actually implement most/all of it. If that happens, it is also ok to put the proposal in the commit message and send a PR. 😃

On user interface level we try to mimic go tool as much as possible. On implementation level I don’t have any concrete thoughts.

I would hope that there would be no interface-level impact at all. go-fuzz-build should “just work” on both module-using and non-module-using packages.

I’m pretty sure @josharian has a master plan here, I just don’t know if he’s made it public 😃

I’m afraid that my master plan was: “get in there and figure it out”.

Any updates on this? I experienced similar problems while trying to fuzz another project. I tried running go-fuzz in the project directory itself and received the unknown import path error. I found that running go-fuzz in /Users/{user}/go worked for me. Not ideal because then the binary is not created in the project directory… but at least it works!