diff options
author | Ian Lance Taylor <iant@golang.org> | 2022-02-18 13:10:34 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2022-02-18 13:12:08 -0800 |
commit | 20a33efdf32bf0aedcb0c9813ddc7572bb1ab8c7 (patch) | |
tree | 94aec72c2092a11fa49f0b45da8e036f13416209 /libgo/go/internal | |
parent | 1931cbad498e625b1e24452dcfffe02539b12224 (diff) | |
download | gcc-20a33efdf32bf0aedcb0c9813ddc7572bb1ab8c7.zip gcc-20a33efdf32bf0aedcb0c9813ddc7572bb1ab8c7.tar.gz gcc-20a33efdf32bf0aedcb0c9813ddc7572bb1ab8c7.tar.bz2 |
libgo: update to Go1.18rc1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/386594
Diffstat (limited to 'libgo/go/internal')
-rw-r--r-- | libgo/go/internal/cfg/cfg.go | 1 | ||||
-rw-r--r-- | libgo/go/internal/fuzz/fuzz.go | 32 | ||||
-rw-r--r-- | libgo/go/internal/fuzz/worker.go | 4 | ||||
-rw-r--r-- | libgo/go/internal/nettrace/nettrace.go | 2 |
4 files changed, 25 insertions, 14 deletions
diff --git a/libgo/go/internal/cfg/cfg.go b/libgo/go/internal/cfg/cfg.go index 4cb3fbd..78664d7 100644 --- a/libgo/go/internal/cfg/cfg.go +++ b/libgo/go/internal/cfg/cfg.go @@ -62,6 +62,7 @@ const KnownEnv = ` GOTOOLDIR GOVCS GOWASM + GOWORK GO_EXTLINK_ENABLED PKG_CONFIG ` diff --git a/libgo/go/internal/fuzz/fuzz.go b/libgo/go/internal/fuzz/fuzz.go index 73f32dd..3ccf747 100644 --- a/libgo/go/internal/fuzz/fuzz.go +++ b/libgo/go/internal/fuzz/fuzz.go @@ -316,12 +316,12 @@ func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err err } else { // Update the coordinator's coverage mask and save the value. inputSize := len(result.entry.Data) - duplicate, err := c.addCorpusEntries(true, result.entry) + entryNew, err := c.addCorpusEntries(true, result.entry) if err != nil { stop(err) break } - if duplicate { + if !entryNew { continue } c.updateCoverage(keepCoverage) @@ -419,11 +419,21 @@ type corpus struct { hashes map[[sha256.Size]byte]bool } +// addCorpusEntries adds entries to the corpus, and optionally writes the entries +// to the cache directory. If an entry is already in the corpus it is skipped. If +// all of the entries are unique, addCorpusEntries returns true and a nil error, +// if at least one of the entries was a duplicate, it returns false and a nil error. func (c *coordinator) addCorpusEntries(addToCache bool, entries ...CorpusEntry) (bool, error) { + noDupes := true for _, e := range entries { - h := sha256.Sum256(e.Data) + data, err := corpusEntryData(e) + if err != nil { + return false, err + } + h := sha256.Sum256(data) if c.corpus.hashes[h] { - return true, nil + noDupes = false + continue } if addToCache { if err := writeToCorpus(&e, c.opts.CacheDir); err != nil { @@ -437,7 +447,7 @@ func (c *coordinator) addCorpusEntries(addToCache bool, entries ...CorpusEntry) c.corpus.hashes[h] = true c.corpus.entries = append(c.corpus.entries, e) } - return false, nil + return noDupes, nil } // CorpusEntry represents an individual input for fuzzing. @@ -468,9 +478,9 @@ type CorpusEntry = struct { IsSeed bool } -// Data returns the raw input bytes, either from the data struct field, -// or from disk. -func CorpusEntryData(ce CorpusEntry) ([]byte, error) { +// corpusEntryData returns the raw input bytes, either from the data struct +// field, or from disk. +func corpusEntryData(ce CorpusEntry) ([]byte, error) { if ce.Data != nil { return ce.Data, nil } @@ -587,7 +597,7 @@ type coordinator struct { // interestingCount is the number of unique interesting values which have // been found this execution. - interestingCount int64 + interestingCount int // warmupInputCount is the count of all entries in the corpus which will // need to be received from workers to run once during warmup, but not fuzz. @@ -721,8 +731,8 @@ func (c *coordinator) logStats() { } else { rate := float64(c.count-c.countLastLog) / now.Sub(c.timeLastLog).Seconds() if coverageEnabled { - interestingTotalCount := int64(c.warmupInputCount-len(c.opts.Seed)) + c.interestingCount - fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, execs: %d (%.0f/sec), new interesting: %d (total: %d)\n", c.elapsed(), c.count, rate, c.interestingCount, interestingTotalCount) + total := c.warmupInputCount + c.interestingCount + fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, execs: %d (%.0f/sec), new interesting: %d (total: %d)\n", c.elapsed(), c.count, rate, c.interestingCount, total) } else { fmt.Fprintf(c.opts.Log, "fuzz: elapsed: %s, execs: %d (%.0f/sec)\n", c.elapsed(), c.count, rate) } diff --git a/libgo/go/internal/fuzz/worker.go b/libgo/go/internal/fuzz/worker.go index c2d5532..e984ba7 100644 --- a/libgo/go/internal/fuzz/worker.go +++ b/libgo/go/internal/fuzz/worker.go @@ -973,7 +973,7 @@ func (wc *workerClient) minimize(ctx context.Context, entryIn CorpusEntry, args return CorpusEntry{}, minimizeResponse{}, errSharedMemClosed } mem.header().count = 0 - inp, err := CorpusEntryData(entryIn) + inp, err := corpusEntryData(entryIn) if err != nil { return CorpusEntry{}, minimizeResponse{}, err } @@ -1059,7 +1059,7 @@ func (wc *workerClient) fuzz(ctx context.Context, entryIn CorpusEntry, args fuzz return CorpusEntry{}, fuzzResponse{}, true, errSharedMemClosed } mem.header().count = 0 - inp, err := CorpusEntryData(entryIn) + inp, err := corpusEntryData(entryIn) if err != nil { return CorpusEntry{}, fuzzResponse{}, true, err } diff --git a/libgo/go/internal/nettrace/nettrace.go b/libgo/go/internal/nettrace/nettrace.go index 94f38a7..6e0dbe7 100644 --- a/libgo/go/internal/nettrace/nettrace.go +++ b/libgo/go/internal/nettrace/nettrace.go @@ -27,7 +27,7 @@ type Trace struct { DNSStart func(name string) // DNSDone is called after a DNS lookup completes (or fails). - // The coalesced parameter is whether singleflight de-dupped + // The coalesced parameter is whether singleflight de-duped // the call. The addrs are of type net.IPAddr but can't // actually be for circular dependency reasons. DNSDone func(netIPs []any, coalesced bool, err error) |