aboutsummaryrefslogtreecommitdiff
path: root/src/internal/fuzz
AgeCommit message (Collapse)Author
2026-03-30all: fix some minor issues in the commentscuishuang
Change-Id: If6c304efac7a46a9718cdc63ded3d98a26a3a831 Reviewed-on: https://go-review.googlesource.com/c/go/+/760700 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Neal Patel <nealpatel@google.com> Reviewed-by: Fred Sauer <fredsa@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
2025-10-17all: remove unnecessary loop variable copies in testsTobias Klauser
Copying the loop variable is no longer necessary since Go 1.22. Change-Id: Iebb21dac44a20ec200567f1d786f105a4ee4999d Reviewed-on: https://go-review.googlesource.com/c/go/+/711640 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-21runtime, internal/fuzz: optimize build tag combination on loong64Guoqi Chen
Change-Id: I971b789beb08e0c6b11169fd5547a8d4ab74fab5 Reviewed-on: https://go-review.googlesource.com/c/go/+/668155 Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-24runtime, internal/fuzz: add comparison tracing for libFuzzer on loong64limeidan
Change-Id: I212330962453139fa353db29928786b64c9ff063 Reviewed-on: https://go-review.googlesource.com/c/go/+/667455 Reviewed-by: abner chenc <chenguoqi@loongson.cn> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-14cmd/go: enable fuzz testing on OpenBSDMaciej Żok
This change provides support for -fuzz flag on OpenBSD. According to #46554 the flag was unsupported on some OSes due to lack of proper testing. Fixes: #60491 Change-Id: I49835131d3ee23f6482583b518b9c5c224fc4efe GitHub-Last-Rev: f697a3c0f2dc36cc3c96c0336281c5e2440f7a1a GitHub-Pull-Request: golang/go#60520 Reviewed-on: https://go-review.googlesource.com/c/go/+/499335 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-02-03internal/fuzz: use a lookup table for SnapshotCoverageJakub Ciolek
Previously, the implementation used bit manipulation to approximate counters to the nearest power of two. Given the 0-255 range of byte, we can precompute values at initialization and use a lookup table, reducing runtime computation. Benchmarks show an 18% performance gain on AMD64 and 5% on ARM64. * net/netip/FuzzParse (n=10, t=60s, state reset per run) * AMD64 (Intel Alder Lake i5-12600k): 17,349,217 -> 20,487,756 execs/s * ARM64 (M3 Pro): 19,606,471 -> 20,657,041 execs/s * compress/gzip/FuzzReader (n=10, t=60s, mature corpus) * AMD64 (Intel Alder Lake i5-12600k): 5,655,956 -> 6,707,035 execs/s Change-Id: If11f7fe866f54c7cd2c5a48e251c027b67980df7 Reviewed-on: https://go-review.googlesource.com/c/go/+/627378 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org>
2025-01-03internal/fuzz: remove the exp2 methodJakub Ciolek
It's not being used anywhere, remove it. Change-Id: I9c3eecacd4e5d44b18243bdec24ad88bc38c82bf Reviewed-on: https://go-review.googlesource.com/c/go/+/639957 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Roland Shoemaker <roland@golang.org>
2024-11-15internal/fuzz: add benchmarks for byte slice mutatorsJakub Ciolek
Cover each byte slice mutation function in a benchmark. Grants visibility into the cost of each transformation and allows us to perform informed optimization. Results on go1.23/Intel Alder Lake i5-12600K (n=16): name time/op ByteSliceMutators/RemoveBytes/64-16 14.8ns ± 0% ByteSliceMutators/RemoveBytes/128-16 14.6ns ± 0% ByteSliceMutators/RemoveBytes/256-16 14.7ns ± 0% ByteSliceMutators/RemoveBytes/512-16 17.0ns ± 0% ByteSliceMutators/RemoveBytes/1024-16 18.3ns ± 0% ByteSliceMutators/InsertRandomBytes/64-16 9.88ns ± 0% ByteSliceMutators/InsertRandomBytes/128-16 9.88ns ± 1% ByteSliceMutators/InsertRandomBytes/256-16 9.87ns ± 0% ByteSliceMutators/InsertRandomBytes/512-16 9.88ns ± 0% ByteSliceMutators/InsertRandomBytes/1024-16 9.87ns ± 0% ByteSliceMutators/DuplicateBytes/64-16 12.4ns ± 0% ByteSliceMutators/DuplicateBytes/128-16 12.3ns ± 0% ByteSliceMutators/DuplicateBytes/256-16 12.3ns ± 0% ByteSliceMutators/DuplicateBytes/512-16 12.3ns ± 0% ByteSliceMutators/DuplicateBytes/1024-16 12.3ns ± 0% ByteSliceMutators/OverwriteBytes/64-16 17.5ns ± 0% ByteSliceMutators/OverwriteBytes/128-16 17.3ns ± 0% ByteSliceMutators/OverwriteBytes/256-16 17.1ns ± 0% ByteSliceMutators/OverwriteBytes/512-16 17.0ns ± 0% ByteSliceMutators/OverwriteBytes/1024-16 17.0ns ± 0% ByteSliceMutators/BitFlip/64-16 5.06ns ± 1% ByteSliceMutators/BitFlip/128-16 5.07ns ± 1% ByteSliceMutators/BitFlip/256-16 5.07ns ± 1% ByteSliceMutators/BitFlip/512-16 5.07ns ± 0% ByteSliceMutators/BitFlip/1024-16 5.06ns ± 1% ByteSliceMutators/XORByte/64-16 5.33ns ± 1% ByteSliceMutators/XORByte/128-16 5.30ns ± 1% ByteSliceMutators/XORByte/256-16 5.29ns ± 1% ByteSliceMutators/XORByte/512-16 5.29ns ± 1% ByteSliceMutators/XORByte/1024-16 5.29ns ± 1% ByteSliceMutators/SwapByte/64-16 5.75ns ± 0% ByteSliceMutators/SwapByte/128-16 5.70ns ± 0% ByteSliceMutators/SwapByte/256-16 5.67ns ± 0% ByteSliceMutators/SwapByte/512-16 5.67ns ± 1% ByteSliceMutators/SwapByte/1024-16 5.67ns ± 0% ByteSliceMutators/ArithmeticUint8/64-16 9.55ns ± 0% ByteSliceMutators/ArithmeticUint8/128-16 9.56ns ± 0% ByteSliceMutators/ArithmeticUint8/256-16 9.57ns ± 0% ByteSliceMutators/ArithmeticUint8/512-16 9.56ns ± 0% ByteSliceMutators/ArithmeticUint8/1024-16 9.56ns ± 0% ByteSliceMutators/ArithmeticUint16/64-16 13.2ns ± 0% ByteSliceMutators/ArithmeticUint16/128-16 13.2ns ± 0% ByteSliceMutators/ArithmeticUint16/256-16 13.2ns ± 0% ByteSliceMutators/ArithmeticUint16/512-16 13.2ns ± 0% ByteSliceMutators/ArithmeticUint16/1024-16 13.2ns ± 0% ByteSliceMutators/ArithmeticUint32/64-16 13.4ns ± 0% ByteSliceMutators/ArithmeticUint32/128-16 13.4ns ± 0% ByteSliceMutators/ArithmeticUint32/256-16 13.4ns ± 0% ByteSliceMutators/ArithmeticUint32/512-16 13.4ns ± 0% ByteSliceMutators/ArithmeticUint32/1024-16 13.4ns ± 0% ByteSliceMutators/ArithmeticUint64/64-16 13.4ns ± 0% ByteSliceMutators/ArithmeticUint64/128-16 13.5ns ± 0% ByteSliceMutators/ArithmeticUint64/256-16 13.5ns ± 0% ByteSliceMutators/ArithmeticUint64/512-16 13.5ns ± 0% ByteSliceMutators/ArithmeticUint64/1024-16 13.5ns ± 0% ByteSliceMutators/OverwriteInterestingUint8/64-16 5.39ns ± 2% ByteSliceMutators/OverwriteInterestingUint8/128-16 5.38ns ± 1% ByteSliceMutators/OverwriteInterestingUint8/256-16 5.37ns ± 1% ByteSliceMutators/OverwriteInterestingUint8/512-16 5.41ns ± 2% ByteSliceMutators/OverwriteInterestingUint8/1024-16 5.38ns ± 0% ByteSliceMutators/OverwriteInterestingUint16/64-16 10.7ns ± 0% ByteSliceMutators/OverwriteInterestingUint16/128-16 10.7ns ± 0% ByteSliceMutators/OverwriteInterestingUint16/256-16 10.7ns ± 0% ByteSliceMutators/OverwriteInterestingUint16/512-16 10.7ns ± 0% ByteSliceMutators/OverwriteInterestingUint16/1024-16 10.7ns ± 0% ByteSliceMutators/OverwriteInterestingUint32/64-16 10.9ns ± 0% ByteSliceMutators/OverwriteInterestingUint32/128-16 10.9ns ± 0% ByteSliceMutators/OverwriteInterestingUint32/256-16 10.9ns ± 0% ByteSliceMutators/OverwriteInterestingUint32/512-16 10.9ns ± 0% ByteSliceMutators/OverwriteInterestingUint32/1024-16 10.9ns ± 0% ByteSliceMutators/InsertConstantBytes/64-16 10.1ns ± 0% ByteSliceMutators/InsertConstantBytes/128-16 10.1ns ± 0% ByteSliceMutators/InsertConstantBytes/256-16 10.1ns ± 0% ByteSliceMutators/InsertConstantBytes/512-16 10.1ns ± 0% ByteSliceMutators/InsertConstantBytes/1024-16 10.1ns ± 0% ByteSliceMutators/OverwriteConstantBytes/64-16 18.7ns ± 0% ByteSliceMutators/OverwriteConstantBytes/128-16 18.8ns ± 0% ByteSliceMutators/OverwriteConstantBytes/256-16 18.8ns ± 0% ByteSliceMutators/OverwriteConstantBytes/512-16 19.0ns ± 0% ByteSliceMutators/OverwriteConstantBytes/1024-16 19.3ns ± 0% ByteSliceMutators/ShuffleBytes/64-16 24.5ns ± 0% ByteSliceMutators/ShuffleBytes/128-16 25.4ns ± 0% ByteSliceMutators/ShuffleBytes/256-16 26.6ns ± 0% ByteSliceMutators/ShuffleBytes/512-16 28.2ns ± 0% ByteSliceMutators/ShuffleBytes/1024-16 33.3ns ± 0% ByteSliceMutators/SwapBytes/64-16 16.2ns ± 1% ByteSliceMutators/SwapBytes/128-16 15.8ns ± 0% ByteSliceMutators/SwapBytes/256-16 15.5ns ± 0% ByteSliceMutators/SwapBytes/512-16 15.4ns ± 0% ByteSliceMutators/SwapBytes/1024-16 15.3ns ± 0% [Geo mean] 11.0ns Note that implementing this via a single parent benchmark function adds an overhead of about 1-8%, but that should be acceptable and results in more concise code. Change-Id: Ifa2693f8fc8c2058513a615208d0d6862efd3617 Reviewed-on: https://go-review.googlesource.com/c/go/+/623895 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-09-25all: fix typos of possessive itsBrad Fitzpatrick
(I noticed the one mistake in hashtriemap.go and figured I'd clean up others.) Change-Id: I4ade424b400056f161bc6c9c2838ba1f96b1f6bb Reviewed-on: https://go-review.googlesource.com/c/go/+/615675 Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-05-08internal/fuzz: fix names of noCopy methodsOleksandr Redko
Must be Lock/Unlock to be flagged by vet. Change-Id: I792ebd68b168621a660b9595b5d06a465d0d7bf2 Reviewed-on: https://go-review.googlesource.com/c/go/+/584355 Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-03-27all: make use of builtin clearJes Cok
Change-Id: I1df0685c75fc1044ba46003a69ecc7dfc53bbc2b Reviewed-on: https://go-review.googlesource.com/c/go/+/574675 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-26all: fix a large number of commentscui fliter
Partial typo corrections, following https://go.dev/wiki/Spelling Change-Id: I2357906ff2ea04305c6357418e4e9556e20375d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/573776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-07internal/fuzz: remove useless codeguoguangwu
Change-Id: I4534a116ef421379b2356bbe80760adae8cdd95f GitHub-Last-Rev: a3fab3f1fa84111f3f3af7cf9f98e964f2423c73 GitHub-Pull-Request: golang/go#65892 Reviewed-on: https://go-review.googlesource.com/c/go/+/566315 Run-TryBot: Tim King <taking@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tim King <taking@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2023-11-17all: make more use of the new atomic integer typesDaniel Martí
Slightly simplifies the code and avoids human error. Change-Id: Ib76575e8bc5b3a699ba6cc3870d63cd7a55e6416 Reviewed-on: https://go-review.googlesource.com/c/go/+/541476 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-18all: clean unnecessary castsJes Cok
Run 'unconvert -safe -apply' (https://github.com/mdempsky/unconvert) Change-Id: I24b7cd7d286cddce86431d8470d15c5f3f0d1106 GitHub-Last-Rev: 022e75384c08bb899a8951ba0daffa0f2e14d5a7 GitHub-Pull-Request: golang/go#62662 Reviewed-on: https://go-review.googlesource.com/c/go/+/528696 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-08-14internal/fuzz: use the built-in min functioncui fliter
Change-Id: I26be9a9faa27c6c03cf8b9dec5908d8617d61312 Reviewed-on: https://go-review.googlesource.com/c/go/+/518276 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-07-20internal/fuzz: pass handle to temporary file instead of the pathqmuntal
This CL partially reverts CL 297034. Inheritable handles are not inherited by all workers thanks to using AdditionalInheritedHandles, which explicitly specifies which handles to inherit by each worker. This CL doesn't fix any bug, it's more of a cleanup, but also makes the code more robust and more similar to its Unix counterpart. Change-Id: I24c2d7f69dfb839a1aeb5858088d8f38b022f702 Reviewed-on: https://go-review.googlesource.com/c/go/+/506535 Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-06-22internal/fuzz: fix typo in commentOleksandr Redko
Change-Id: I04f0aa2730cd7d60027a36a3b81289e4972d4a9c Reviewed-on: https://go-review.googlesource.com/c/go/+/505115 Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-04-18cmd/go: add check for unknown godebug settingRuss Cox
A //go:debug line mentioning an unknown or retired setting should be diagnosed as making the program invalid. Do that. We agreed on this in the proposal but I forgot to implement it. Change-Id: Ie69072a1682d4eeb6866c02adbbb426f608567c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/476280 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-03-16internal/fuzz: release lock when reading file failsRoland Shoemaker
When corpusEntryData failed in workerClient.fuzz and workerClient.minimize, the shared memory mutex wasn't properly given up, which would cause a deadlock when worker.cleanup was called. This was tickled by #59062, wherein the fuzz cache directory would be removed during operation of the fuzzer, causing corpusEntryData to fail because the entry files no longer existed. Updates #51484 Change-Id: Iea284041c20d1581c662bddbbc7e12191771a364 Reviewed-on: https://go-review.googlesource.com/c/go/+/476815 Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-03-16internal/fuzz: fix debug statementRoland Shoemaker
Meant to check if the slice was empty, accidentally dumped the entire slice to stdout... Change-Id: I968cb2f20ffb006e4dcfea65a1bad794aac05d17 Reviewed-on: https://go-review.googlesource.com/c/go/+/476795 Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org>
2023-03-16internal/fuzz: more debug loggingRoland Shoemaker
Change-Id: I2c36baf423dde419aaa940ce9308088f3bf431f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/476718 Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2023-03-15internal/fuzz: improve debugging messagesRoland Shoemaker
Also enable debugging information in TestScript/test_fuzz_cov, which hits a deadlock on builders, but I am unable to trigger locally. This should make it somewhat easier to track down where the issue actually is. Updates #51484 Change-Id: I98124f862242798f2d9eba15cacefbd02924cfe2 Reviewed-on: https://go-review.googlesource.com/c/go/+/476595 Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-03-10internal/fuzz: avoid deadlock on duplicate entries with exec limitRoland Shoemaker
If there was a execution limit enabled, and a result put us beyond that limit, but the result expanded coverage *and* was a duplicate of an entry already in the cache, the check if we were passed the limit would be skipped. Since this check was inside the result check body, and we would no longer send any new inputs, we'd never get to that check again, causing the coordinator to just sit in an infinite loop. This moves the check up to the top of the coordinator loop, so that it is checked after every result is processed. Also add a cmd/go TestScript regression test which triggered this case much more frequently. Updates #51484 Change-Id: I7a2181051177acb853c1009beedd334a40796177 Reviewed-on: https://go-review.googlesource.com/c/go/+/475196 Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-18all: add missing periods in commentscui fliter
Change-Id: I69065f8adf101fdb28682c55997f503013a50e29 Reviewed-on: https://go-review.googlesource.com/c/go/+/449757 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joedian Reid <joedian@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-11-14internal/godebug: define more efficient APIRuss Cox
We have been expanding our use of GODEBUG for compatibility, and the current implementation forces a tradeoff between freshness and efficiency. It parses the environment variable in full each time it is called, which is expensive. But if clients cache the result, they won't respond to run-time GODEBUG changes, as happened with x509sha1 (#56436). This CL changes the GODEBUG API to provide efficient, up-to-date results. Instead of a single Get function, New returns a *godebug.Setting that itself has a Get method. Clients can save the result of New, which is no more expensive than errors.New, in a global variable, and then call that variable's Get method to get the value. Get costs only two atomic loads in the case where the variable hasn't changed since the last call. Unfortunately, these changes do require importing sync from godebug, which will mean that sync itself will never be able to use a GODEBUG setting. That doesn't seem like such a hardship. If it was really necessary, the runtime could pass a setting to package sync itself at startup, with the caveat that that setting, like the ones used by runtime itself, would not respond to run-time GODEBUG changes. Change-Id: I99a3acfa24fb2a692610af26a5d14bbc62c966ac Reviewed-on: https://go-review.googlesource.com/c/go/+/449504 Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-05all: fix comment typosDan Kortschak
Change-Id: Ic16824482142d4de4d0b949459e36505ee944ff7 Reviewed-on: https://go-review.googlesource.com/c/go/+/448175 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Dan Kortschak <dan@kortschak.io> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dan Kortschak <dan@kortschak.io> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-10-17internal/fuzz: write shorter testdata corpus file namesRuss Cox
The only purpose of using the SHA256 in the file name is collision avoidance. Using just the first 64 bits (16 hex digits) will be more than enough, unless people start storing billions of test cases in their corpora. The shorter names are nicer for just about everything: command lines, repository listings, and so on. Change-Id: I67c760023bed85ba3ffd4f8058f86ef778322ba7 Reviewed-on: https://go-review.googlesource.com/c/go/+/443335 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com> Run-TryBot: Russ Cox <rsc@golang.org>
2022-10-12all: prevent fakePC overflow on 386 in libfuzzer modeCuong Manh Le
fakePC uses hash.Sum32, which returns an uint32. However, libfuzzer trace/hook functions declare fakePC argument as int, causing overflow on 386 archs. Fixing this by changing fakePC argument to uint to prevent the overflow. Fixes #56141 Change-Id: I3994c461319983ab70065f90bf61539a363e0a2a Reviewed-on: https://go-review.googlesource.com/c/go/+/441996 Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-10-04cmd/internal/sys: migrate support.go functions to new internal pkgThan McIntosh
Separate out the functions from cmd/internal/sys/support.go and migrate them to a new package internal/platform, so that functions such as "RaceDetectorSupported" can be called from tests in std as well as in cmd. This isn't a complete move of everything in cmd/internal/sys; there are still many functions left. The original version of this CL (patch set 1) called the new package "internal/sys", but for packages that needed both "internal/sys" and "cmd/internal/sys" the import of the former had to be done with a different name, which was confusing and also required a hack in cmd/dist. Updates #56006. Change-Id: I866d62e75adbf3a640a06e2c7386a6e9e2a18d91 Reviewed-on: https://go-review.googlesource.com/c/go/+/438475 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Than McIntosh <thanm@google.com>
2022-09-30internal: fix a few function names on commentscui fliter
Change-Id: I53169e386b8c789b092de348fa891fe50e11c2ef GitHub-Last-Rev: 75232393b4ba415bddc731f15550d7094ccfd953 GitHub-Pull-Request: golang/go#55965 Reviewed-on: https://go-review.googlesource.com/c/go/+/436883 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-29internal: use time.Since instead of time.Now().Subcuiweixie
Change-Id: I536c7fad84a63e96658c6930a5a77fd70edca33c Reviewed-on: https://go-review.googlesource.com/c/go/+/436718 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-28internal: use bytes.Clonecuiweixie
Change-Id: Ia96ddd520a7bd2fd53bff55315c6fac04ae96a2f Reviewed-on: https://go-review.googlesource.com/c/go/+/435282 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
2022-09-20all: replace package ioutil with os and io in srcAndy Pan
For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-08all: use unsafe.{Slice, SliceData, String, StringData} to simplify codehopehook
Because most of these APIs are recently supported, we can only do some advancement work as much as possible under the premise of compatibility. For #54854. Change-Id: Id15d11288bf23902570d54eaf2704a5264210b2e Reviewed-on: https://go-review.googlesource.com/c/go/+/429115 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: hopehook <hopehook@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-09-07internal/fuzz: simplify code using unsafe.{SliceData,Slice}cuiweixie
Updates #54854 Change-Id: If70b11c0fc920b7214fcff249da9e3c4ac1de991 Reviewed-on: https://go-review.googlesource.com/c/go/+/428156 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
2022-07-25internal/fuzz: fix typo in function commentsAbirdcfly
The correct word to use here is 'retrieve' not 'retrive' Change-Id: I8de0961a254cf429ddbaf599fe996155e24c7af2 GitHub-Last-Rev: 65aaeec8db14c23e7bc8a62ce9ecfde98a263a49 GitHub-Pull-Request: golang/go#54026 Reviewed-on: https://go-review.googlesource.com/c/go/+/419317 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-05-23cmd/compile: support libFuzzer value profiling mode for integer comparesKhaled Yakdan
libFuzzer provides a special mode known as “value profiling” in which it tracks the bit-wise progress made by the fuzzer in satisfying tracked comparisons. Furthermore, libFuzzer uses the value of the return address in its hooks to distinguish the progress for different comparisons. The original implementation of the interception for integer comparisons in Go simply called the libFuzzer hooks from a function written in Go assembly. The libFuzzer hooks thus always see the same return address (i.e., the address of the call instruction in the assembly snippet) and thus can’t distinguish individual comparisons anymore. This drastically reduces the usefulness of value profiling. This is fixed by using an assembly trampoline that injects synthetic but valid return addresses on the stack before calling the libFuzzer hook, otherwise preserving the calling convention of the respective platform (for starters, x86_64 Windows or Unix). These fake PCs are generated deterministically based on the location of the compare instruction in the IR representation. Change-Id: Iea68057c83aea7f9dc226fba7128708e8637d07a GitHub-Last-Rev: f9184baafd507eb4c31f7d99b3894595689d8f89 GitHub-Pull-Request: golang/go#51321 Reviewed-on: https://go-review.googlesource.com/c/go/+/387336 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2022-05-20internal/fuzz: trim carriage return from version lineDan Kortschak
On windows hosts, when code is checked out using git with the default setting of autocrlf=true, carriage returns are appended to source lines which then prevent the version check from being successful. This removes carriage returns to allow version matching. Fixes #52268 Change-Id: I9acc4e907c93a20305f8742cc01687a122a88645 Reviewed-on: https://go-review.googlesource.com/c/go/+/402074 Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dan Kortschak <dan@kortschak.io> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-20cmd/compile: intercept string compares in libFuzzer modeKhaled Yakdan
IR string compares as well as calls to string comparison functions such as `strings.EqualFold` are intercepted and the corresponding libFuzzer callbacks are invoked with the corresponding arguments. As a result, the compared strings will be added to libFuzzer’s table of recent compares, which feeds future mutations performed by the fuzzer and thus allow it to reach into branches guarded by string comparisons. The list of methods to intercept is maintained in `cmd/compile/internal/walk/expr.go` and can easily be extended to cover more standard library functions in the future. Change-Id: I5c8b89499c4e19459406795dea923bf777779c51 GitHub-Last-Rev: 6b8529b55561faf57ea59cb7cff1caf8c9c94ecd GitHub-Pull-Request: golang/go#51319 Reviewed-on: https://go-review.googlesource.com/c/go/+/387335 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2022-03-10internal/fuzz: minimization should not reduce coverageSteven Johnstone
Minimization should result in a fuzz input which includes the same coverage bits as the original input. Updates #48326 Change-Id: I6c5f30058b57ccd1a096ad0e9452a4dfbb7d9aab Reviewed-on: https://go-review.googlesource.com/c/go/+/391454 Trust: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-10internal/fuzz: don't use dirty coverage maps during minimizationRoland Shoemaker
When minimizing a value, if the value cannot be minimized (i.e. it is the final value is the same value as was sent for minimization) return the initial coverage map, rather than the coverageSnapshot, which is actually the coverage map for the final minimization step and may not accurately reflect whether the input actually expands the coverage set or not. Updates #48326 Change-Id: I01f0eebe5841e808b6799647d2e5fe3aa45cd2e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/391614 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-08internal/fuzz: fix encoding for out-of-range ints and runesBryan C. Mills
Also switch float64 NaN encoding to use hexadecimal, and accept hexadecimal encoding for all other integer types too. (That gives us the flexibility to change the encodings in either direction in the future without breaking earlier Go versions.) Out-of-range runes encoded using "%q" were previously replaced with the Unicode replacement charecter, losing their values. Out-of-range ints and uints on 32-bit platforms were previously rejected. Now they are wrapped instead: an “interesting” case with a large int or uint found on a 64-bit platform likely remains interesting on a 32-bit platform, even if the specific values differ. To verify the above changes, I have made TestMarshalUnmarshal accept (and check for) arbitrary differences between input and output, and added tests cases that include values in valid but non-canonical encodings. I have also added round-trip fuzz tests in the opposite direction for most of the types affected by this change, verifying that a marshaled value unmarshals to the same bitwise value. Updates #51258 Updates #51526 Fixes #51528 Change-Id: I7727a9d0582d81be0d954529545678a4374e88ed Reviewed-on: https://go-review.googlesource.com/c/go/+/390424 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-07internal/fuzz: fix TestUnmarshalMarshal on MIPSRoland Shoemaker
Previous value used in the float32 roundtrip used float32(math.NaN())-1 which caused the quiet/signal bit to flip, which seemed to break the test on MIPS platforms. Instead switch to using float32(math.NaN())+1, which preserves the bit and makes the test happy. Possibly related to #37455 Fixes #51258 Change-Id: Ia85c649e89a5d02027c0ec197f0ff318aa819c19 Reviewed-on: https://go-review.googlesource.com/c/go/+/390214 Trust: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-04internal/fuzz: handle Inf/NaN float valuesRoland Shoemaker
Fixes #51258 Change-Id: I3c8b785ac912d66e1a6e2179625e6903032b8330 Reviewed-on: https://go-review.googlesource.com/c/go/+/388354 Reviewed-by: Bryan Mills <bcmills@google.com> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-04internal/fuzz: change meaning of "total" in outputKatie Hockman
Fixes #51023 Change-Id: I7dd9f7c696e15ba9c6c887d4c4e0f4d281a82b17 Reviewed-on: https://go-review.googlesource.com/c/go/+/383414 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-02internal/fuzz: small cleanupsKatie Hockman
Change-Id: I9fc12f352d57db776d176990277e104f64f9908d Reviewed-on: https://go-review.googlesource.com/c/go/+/382238 Reviewed-by: Julie Qiu <julie@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-01internal/fuzz: properly handle duplicates during cache loadingRoland Shoemaker
When loading the corpus, if the cache contained an entry which was a duplicate of an entry added using f.Add, coordinator.addCorpusEntries would return early, ignoring everything after this entry in the cache. Instead, skip duplicates as intended, and continue to load the rest of the cache. Fixes #50913 Change-Id: I3a64b93cbb217c5c364a9f8d0005752e9e9d10ff Reviewed-on: https://go-review.googlesource.com/c/go/+/381960 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-27internal/fuzz: centralize corpus entry additionRoland Shoemaker
Adds an addCorpusEntry method to coordinator which manages checking for duplicate entries, writing entries to the cache directory, and adding entries to the corpus. Also moves readCache to be a method on the coordinator. Fixes #50606 Change-Id: Id6721384a2ad1cfb4c5471cf0cd0a7510d250a6c Reviewed-on: https://go-review.googlesource.com/c/go/+/360394 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-12cmd/go: enable fuzz testing for FreeBSDAyan George
Add "freebsd" to GOOS for which sys.FuzzSupported() returns true and add freebsd to the build tags to fuzz test source. Fixes #46554 Change-Id: I5f695ecc8f09c0ab4279ced23b4715b788fcade0 Reviewed-on: https://go-review.googlesource.com/c/go/+/377855 Trust: Bryan Mills <bcmills@google.com> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org>