Finding Go bugs that fuzzing misses: Gemini combined with a constraint solver

In this article
Fuzzing with go test -fuzz misses some bounds-overflow bugs in Go, and a workflow combining Gemini 4 Argon with the Z3 constraint solver can catch them. The author uses skill-lint, a Go CLI that checks SKILL.md files, as the test subject. The workflow caught all three bugs planted in the test parsers and uncovered three latent bugs in skill-lint, while default fuzzing missed two of the planted bugs. A one-line change helps the fuzzer overcome this blind spot.
How the constraint-solving workflow works
In Go, every slice operation or index access that can panic at runtime is compiled into an explicit bounds-check branch, after the optimizer has removed the checks it can prove safe. The SSA prove pass tracks slice lengths and loop variables to eliminate most checks. The runtime.panicBounds traps that remain are the short list of possible crash points for the solver to target. This approach is inspired by an Anthropic post about using formal verification to catch bugs in C and C++: instead of sampling random inputs like a fuzzer, the formal tool works backward from the failure condition to find the exact input that triggers it.
The steps are as follows:
Looking at Go source code alone, you cannot see which bounds checks have been removed or where a register gets truncated to 8 bits; the disassembly shows both. RISC-V was chosen because it is the instruction set targeted by Anthropic's post and Go cross-compiles to it out of the box. Using an LLM saves you from translating assembly into constraints by hand. Run time is dominated by Argon's translation step, about one minute per function, while Z3 finishes in a few milliseconds.
When to trust the solver's results
Anthropic's approach relies on interactive theorem proving, where experts model the machine semantics and Rocq checks the proofs generated by the LLM. The workflow here uses a solver based on satisfiability modulo theories (SMT), letting Argon translate assembly directly into Z3 constraints. Without a semantic model, the solver does not give a fully sound proof, but it is very effective at finding bugs. Z3's check-sat command returns sat when the input constraints are satisfiable and unsat when they are not.
The scope of checking also differs from Anthropic's: they prove a no-crash property over a whole binary with a 64 MB budget, whereas here each function is checked on 64-byte slices with cap(buf) == len(buf), so any slice beyond len(buf) panics. If you want to set up Rocq for a whole Go binary, theorem-labs/oss-verify has a Go 1.27 runtime overlay that makes the runtime single-threaded and deterministic.
Why Go's fuzzer misses one fifth of the bugs
func ParseTwoChunkFrame(buf []byte) ([]byte, []byte) {
if len(buf) < 4 || buf[0] != 0xA5 || buf[1] != 0x5A {
return nil, nil
}
hdrLen, bodyLen := buf[2], buf[3]
total := hdrLen + bodyLen
if int(total)+4 > len(buf) {
return nil, nil
}
endHdr := 4 + int(hdrLen)
endBody := endHdr + int(bodyLen)
return buf[4:endHdr], buf[endHdr:endBody]
}The fix is to clip capacity to length with a full slice expression, so that every access beyond len panics:
f.Fuzz(func(t *testing.T, data []byte) {
data = data[:len(data):len(data)] // cap == len: slicing past the end now panics
ParseTwoChunkFrame(data)
})After this change, the fuzzer crashed both ParseTwoChunkFrame and ExtractQuotedToken in all three runs. The third target, ParseMagicPacket, serves as a control because the signed int8 length bug causes a negative-index panic regardless of capacity, and the fuzzer found it in every run. Even so, fuzzing still cannot produce an unsat signal on the remaining paths, which is what is used to check the three safe parsers and Argon's patches.
Applying it to skill-lint
Handing an entire Go CLI to the solver is too much: even a 10-line parser links 1,559 symbols from the Go runtime, and the 28 MB skill-lint binary has 32,321 symbols in total. Following the Functional Core, Imperative Shell principle, the author leaves CLI flags, network calls and file I/O to go test -fuzz and go test -race, while the solver runs only on pure functions and slice helpers split out from the file-reading code. Of the five functions tried, two scanners returned unsat (including a CRLF line splitter with six remaining bounds checks), and the other three had bugs.
In the local fixer, the target line number is checked once per violation before the inner chunk loop applies the deletions that shrink the slice. This is a latent bug if a fixer returns a second chunk after a deletion, even though DeleteLineFix currently returns only one chunk.
In the prompt packer, the truncation check reserves a fixed 100 bytes for a roughly 70-byte wrapper plus the file path. This exceeds the 2 MB context budget in the release code when the path is more than about 30 bytes longer, and it causes a panic in the split-out helper.
When checking module by module like this, the target must include its own entry-point guards, such as the bounds check and the sorting step in ApplyReplacementChunks. If an internal function assumes preconditions that are guaranteed only by the caller or documented in comments, Z3 will invent inputs that violate them. Because each split-out function came with input guards, there were no false positives: for all six buggy functions, Z3's first sat assignment caused a real panic in go test. Once these functions were separated from file I/O, a single 3-second fuzz run also caught all three bugs. When rerun with all comments stripped, Argon and Z3 still caught all three bugs and returned unsat for both scanners and all three patches.
Where this approach fits in everyday Go workflows
For most Go code, fuzzing pure functions with capacity clipped to length catches bounds bugs in a few seconds.
The solver is worth an extra minute for traps that survive both the compiler's range-proving pass and a quick fuzz run, especially in parsers and editors that compute offsets from multi-field headers or line ranges.
The single-threaded solver model cannot see data races or deadlocks, so concurrent code still belongs to the race detector, deterministic concurrency testing and Go 1.27's goroutine leak profiles.


