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 #2

Closed
andrewchambers opened this issue Apr 25, 2015 · 9 comments
Closed

go-fuzz-build fails #2

andrewchambers opened this issue Apr 25, 2015 · 9 comments

Comments

@andrewchambers
Copy link

Execute go-fuzz-build as the readme suggests.

andrew@andrew-laptop:fuzz $ go version
go version devel +ada8cdb Fri Apr 24 21:52:30 2015 +0000 linux/amd64
andrew@andrew-laptop:fuzz $ go get github.com/dvyukov/go-fuzz/...
andrew@andrew-laptop:fuzz $ go-fuzz-build github.com/dvyukov/go-fuzz/examples/png
failed to scan dir 'pkg/tool': open pkg/tool: no such file or directory
@dvyukov
Copy link
Owner

dvyukov commented Apr 25, 2015

Do you have GOROOT set? Do you use go1.4 or tip?
I have GOROOT set and use tip.

@andrewchambers
Copy link
Author

tip, I just updated, no GOROOT.

@dvyukov
Copy link
Owner

dvyukov commented Apr 25, 2015

what if you set GOROOT to go installation dir?

@andrewchambers
Copy link
Author

build works with GOROOT.

@dvyukov
Copy link
Owner

dvyukov commented Apr 25, 2015

Added diagnostic to go-fuzz-build, now it says:

GOROOT env var is not set, set it to Go installation dir

thanks!

@dvyukov dvyukov closed this as completed Apr 25, 2015
@FiloSottile
Copy link
Contributor

The message seems gone:

go-fuzz-build REDACTED
failed to execute go build: exit status 1
../../../REDACTED: cannot find package "bufio" in any of:
    /usr/local/src/bufio (from $GOROOT)

@dvyukov
Copy link
Owner

dvyukov commented May 10, 2015

@FiloSottile can you provide a reproducer?
Have you checkout the latest version of go-fuzz? I've fixed an issue that could lead to the error you see some time ago.

@dvyukov
Copy link
Owner

dvyukov commented May 10, 2015

@FiloSottile and yes, the GOROOT is now inferred from go command location. In your case it is inferred to be /usr/local.

@FiloSottile
Copy link
Contributor

Ah, then there's the problem; the go binary can be stored or linked wherever. I'll make a PR.

josharian pushed a commit that referenced this issue Oct 22, 2019
* preliminary Go modules support (#2)

#### Summary 

The heart of the change is very small -- we stop overwriting the user's value for the `GO111MODULE` env var in two places. This means we end up respecting whatever the user has set for `GO111MODULE`, and relying on `cmd/go` to interpret the meaning of an unset `GO111MODULE` (which defaults to `auto` for Go 1.11-1.13, and likely will default to `on` at some point during Go 1.14 development).

In addition, there are some comments added, as well as an explicit check for `GOFLAGS=-mod=vendor`, which is not supported.

The tests exercises 'replace' directives, v2+ modules, GO111MODULE set to on|off|auto, running inside GOPATH, running outside GOPATH, the mechanisms by which go-fuzz/go-fuzz-dep is found, as well as vendoring (which is not supported, but it tests that a sensible error is emitted). 

#### Additional Details

Historically, go-fuzz has set up a clean GOPATH environment in a temp directory, instrumented the code for fuzzing coverage, and built the instrumented code in the temp directory.

The current approach is to keep doing that (and not set up a full-blown modules-based environment for building), but use modules to find the code to instrument.

v2+ modules are potentially problematic due to Semantic Import Versioning (with the major version in the import path). However, it turns out to not be too bad to handle it. For a v2+ module created following the 'major branch' approach, the /vN is materialized into a physical directory. For example, the github.com/russross/blackfriday/v2 module ends up in the /tmp/blah/gopath/src/github.com/russross/blackfriday/v2 directory. This should be a valid layout, and people use this layout today (including when manually switching to a 'major subdirectory' approach for a v2+ module, which involves creating a /v2 or /vN directory so that pre-modules toolchains follow a /v2 or /vN import path and find an on-disk layout that they expect without any knowledge of modules).

The approach does not copy go.mod files at all. (Before starting, I was thinking I would need to copy go.mod files to trigger "minimal module awareness", which is a transitional mechanism within cmd/go, but after some experimentation / thinking, I concluded it was not needed based on materializing the /v2).

For tests, I am using the script-driven test facility that the core Go team created for testing cmd/go, which is well tuned to testing the various permutations of modules, including it lets you relatively easily set up go.mod files and source files, run commands and check results. (Some more details of the capability here: https://github.com/golang/go/blob/master/src/cmd/go/testdata/script/README).

* modules support: adjust wording based on first-pass review, and update vendor test (#3)

* travis: attempt to install cmd/testscript

* testing: initial check of 'go-fuzz-build -h' output to see if any testscripts work

* testing: change name of first test script

* travis: check if the 'testscript' cmd seems to function at all.

* testing: use the exec command to invoke 'go-fuzz-build -h'

* testing: create initially failing test case for v2 modules

* travis: run testscript for v2 modules

* testing: remember to use 'exec' to invoke go-fuzz-build

* testing: adjust comments in v2 module testscript

* go-fuzz-build: preliminary module support

* testing: flip  from an expected failure to an expected pass for a module test

* go-fuzz-build: update comments for preliminary modules support

* go-fuzz: preliminary modules support for go-fuzz itself

* travis: go-fuzz-defs sanity check

* travis: additional temp sanity check

* travis: add more comments, some additional sanity checks in case we need to debug in future

* travis: s/go-fuzz-deps/go-fuzz-dep/

* testing: validate behavior of v2 modules

* testing: renamed fuzz_help.txt

* testing: update travis to use the renamed testscripts

* travis: conditionally set GO111MODULE=auto, and test Go 1.13 rather than 1.11

* testing: validate modules outside GOPATH

* testing: validate modules inside GOPATH

* testing: invoke timeout properly

* testing: preliminary test for vendored modules (not yet supported)

* testing: validate how go-fuzz-dep and go-fuzz-defs are found

* travis: run the latest testscripts for modules testing

* testing: fix typo in mod_outside_gopath.txt file name

* travis: fix typo in file name

* go-fuzz-build: detect -mod=vendor

* testing: validate we get a proper error for -mod=vendor

* readme: describe preliminary modules support

* readme: correct typo in modules support

* readme: adjust modules support section

* readme: tweak wording based on PR review

* go-fuzz: tweak comment wording by removing "preliminary modules support"

* go-fuzz-build: tweak comment wording by removing "preliminary modules support"

* mod_vendor.txt: avoid triggering Go 1.14 auto detection of a vendor directory

* readme: update wording based on review

* readme: remove a blank line to re-trigger travis
jsoroka added a commit to jsoroka/go-fuzz that referenced this issue Apr 3, 2022
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

3 participants