Skip to content

Explicitly disable Go modules via GO111MODULE=off for go-fuzz corpus #2878

@thepudds

Description

@thepudds

Background

Go modules are currently an opt-in feature of the go command. The GO111MODULE env var controls when module-mode is enabled for the go command.

go-fuzz does not currently support module-mode, but that might change soon.

Suggested change

It would be helpful to explicitly set GO111MODULE=off within oss-fuzz for projects/golang.

The oss-fuzz change could look something like this.

The history is a bit confusing, but in short, it is likely better for oss-fuzz to be explicitly in control over whether or not module-mode is enabled by setting GO111MODULE explicitly, rather than being surprised on a random day by one or more upstream changes that are likely to happen.

Additional details

This might be more detail than is interesting, but a bit more about the history here, as well as more on the rationale for this change:

  • The go command's default value for GO111MODULE did change twice during Go 1.13 dev cycle — first the default was changed from auto to on, and then later that was reversed. The first time it changed to default to on, that caused breakage for oss-fuzz (for example in Golang internal library fuzzers #2188 (comment)).
  • When that breakage happened for oss-fuzz during the Go 1.13 dev cycle, there was a temporary workaround introduced in go-fuzz of setting GO111MODULE=off within go-fuzz itself.
  • Although the details are still being worked out (e.g., go-fuzz-build doesn't work with go modules (go 1.11.2) dvyukov/go-fuzz#195), most likely as part of adding support for fuzzing modules, go-fuzz will be removing that temporary workaround of always setting GO111MODULE=off (and most likely go-fuzz will start respecting the user's setting for GO111MODULE at least to some degree).
  • The go command's default value for GO111MODULE is planned to be changed again to default to on during the Go 1.14 development cycle (which is a second try at the same change that broke oss-fuzz in Golang internal library fuzzers #2188 (comment)).
  • If both of those things happen without any change on the oss-fuzz side, then the fuzzing of projects/golang on oss-fuzz would likely break. Rather than that happening on a random day, it is better to have more explicit control within oss-fuzz itself by disabling GO111MODULE explicitly as suggested in this issue.
  • Right now, none of the packages at dvyukov/go-fuzz-corpus/... are modules, which means no one is relying on module mode being enabled (and in fact, if someone was relying on module-mode being enabled, it wouldn't work for them currently because go-fuzz does not yet support modules).

Alternatives

Two alternatives to consider:

  1. Rather than setting GO111MODULE=off in the build.sh, set it in the docker file. That could be a reasonable choice as well. My guess is it makes more sense in build.sh, but the right answer here is probably dependent on the oss-fuzz philosophy.
  2. Rather than setting GO111MODULE=off, set GO111MODULE=auto. That could be a reasonable choice currently, but I think from oss-fuzz perspective, it is probably a more conservative change to do GO111MODULE=off, including because go-fuzz currently sets GO111MODULE=off (and not GO111MODULE=auto), and also the meaning of auto changed during the Go 1.13 dev cycle and some small-ish chance the meaning of auto might change again on a random day during the Go 1.14 dev cycle, and hence slightly more future proof to not use auto.

CC @dvyukov @josharian @Dor1s @guidovranken @mvdan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions