TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Go Fuzzing

269 pointsby 0xedbover 3 years ago

8 comments

jrockwayover 3 years ago
Like many others, this was the wakeup call I needed to download go1.18beta1 and start writing some fuzz tests. I unleashed it upon my JSON log viewer, which has the goal of never suppressing a line even in the face of egregious parse errors. (The last thing you need when software goes wrong is your UI hiding stuff from you, after all.)<p>As expected, within seconds it found that the input `{&quot;&quot;: 0}` causes a panic. (This is a weird special case that I handled for other classes of this problem, but not this exact case!) I also got to see what happens when you have more bytes on a line than bufio.MaxScanTokenSize and realized that that is pretty low for an interactive program, especially when all you can do is exit.<p>The ergonomics are excellent. When the fuzzer finds a failing input, it creates a file that contains the test case. You check this in and future invocations of plain &quot;go test .&#x2F;...&quot; will use this input. &quot;go test -fuzz=FuzzWhatever what&#x2F;ever&quot; will cause it to search for more failing inputs. Really well-designed.
评论 #29766371 未加载
xiaqover 3 years ago
Fuzzing is awesome. I just discovered an accidental O(2^n) code path in my project with fuzzing and fixed it: <a href="https:&#x2F;&#x2F;github.com&#x2F;elves&#x2F;elvish&#x2F;commit&#x2F;9cda3f643efafce2df5671bbdd609b11b4b910d5" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;elves&#x2F;elvish&#x2F;commit&#x2F;9cda3f643efafce2df567...</a><p>Edit: shortly after I wrote this comment, fuzzing discovered another pathological input - and that was fixed in <a href="https:&#x2F;&#x2F;github.com&#x2F;elves&#x2F;elvish&#x2F;commit&#x2F;04173ee8ab3c7fc4a9e793f70a1e3b58b82d3728" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;elves&#x2F;elvish&#x2F;commit&#x2F;04173ee8ab3c7fc4a9e79...</a><p>(In case people are curious, the project is a Unix shell, Elvish: <a href="https:&#x2F;&#x2F;elv.sh" rel="nofollow">https:&#x2F;&#x2F;elv.sh</a>)
评论 #29763981 未加载
staticassertionover 3 years ago
Great to see fuzzing becoming more mainstream. Ultimately we have absurd program states, with even a trivial program&#x27;s state vastly exceeding the number of particles in the universe. We need to start finding order-of-magnitude-better approaches for testing.<p>I almost always write generated tests at this point with unit tests being a fallback for slow code or niche cases. What I <i>dont</i> generally write though is fuzz tests, which would really be a &#x27;next step&#x27;. In Rust it&#x27;s not very hard to do so, but it hasn&#x27;t quite hit the &quot;trivial&quot; mark yet for me, whereas quickcheck is virtually the same amount of work to use as to not use.<p>Languages like Go adopting and mainstreaming these practices will be a benefit to everyone.<p>I&#x27;m curious if there&#x27;s documentation on:<p>a) The coverage approach taken<p>b) The mutation approach taken<p>Can you configure these? Plugin different fuzzing backends?
评论 #29762964 未加载
评论 #29762990 未加载
评论 #29761853 未加载
评论 #29778556 未加载
ryanschneiderover 3 years ago
Anyone seen good articles on converting go-fuzz tests to native fuzzing? Specifics on the new corpus format and a converter from go-fuzz would be really useful.<p>It’s great to hear that the fuzzer is built on go-fuzz so hopefully the conversion process won’t be too bad: <a href="https:&#x2F;&#x2F;github.com&#x2F;dvyukov&#x2F;go-fuzz&#x2F;issues&#x2F;329" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dvyukov&#x2F;go-fuzz&#x2F;issues&#x2F;329</a>
评论 #29761756 未加载
评论 #29762856 未加载
dangover 3 years ago
Past related thread:<p><i>Go: Fuzzing Is Beta Ready</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27391048" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=27391048</a> - June 2021 (53 comments)
cinntaileover 3 years ago
What would you say are the main differences between a fuzzer and QuickCheck? The authors of quickcheck don&#x27;t call it a fuzzer so I assume there is some difference but both seem to randomize inputs?
评论 #29763854 未加载
评论 #29763822 未加载
评论 #29767344 未加载
stevekempover 3 years ago
I guess I&#x27;m echoing others here, but fuzzing is magical. I&#x27;ve given introductions to fuzz-testing to more than a few developers, and found interesting bugs in my own code using them.<p>Until now I&#x27;ve used &quot;go-fuzz&quot;, but I&#x27;m very much looking forward to having real integrated fuzzing in the standard compiler&#x2F;toolchain. That has to make things easier to explain and add to more projects.<p>Even with &quot;100% test coverage&quot; finding bugs due to fuzzing shows how hard testing can be.
damagednoobover 3 years ago
I will never understand why this has been included in the standard library instead of as a standalone library available for download. Now it&#x27;s locked to the Go release cycle and have the potential to languish because of backward compatibility concerns.<p>The decision to include it is perplexing when other language ecosystems have chosen to keep this kind of functionality out of the standard lib, e.g. requests in python[1]. To quote Kenneth Reitz: &quot;...the standard library is where a library goes to die.&quot;<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;psf&#x2F;requests&#x2F;issues&#x2F;2424" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;psf&#x2F;requests&#x2F;issues&#x2F;2424</a>
评论 #29761779 未加载
评论 #29761898 未加载
评论 #29761726 未加载
评论 #29761716 未加载
评论 #29761693 未加载
评论 #29769274 未加载
评论 #29761672 未加载
评论 #29765662 未加载
评论 #29767964 未加载