Discarding nil interfaces consumes following gob data

perfloop-oss/go · Value Kind Confusion

https://perfloop.ai/t/oss/case_ftabtx7h5c

Verdict

VERIFIED · settled 2026-11-09 · pull request opened as golang/go#82942

What happened: The check fails before this change and passes with it.

Hypothesis

Discarding a nil interface keeps reading data that belongs to the following field or stream value. This can reject a valid gob value when the receiving schema omits a field. The frequency of affected consumer schemas is unknown; this is a correctness repair, not a measured performance claim.

The package documentation promises to ignore source struct fields absent from the receiver. It also says a nil interface is an empty type name with no following value. Encoder.encodeInterface emits only that marker, and Decoder.decodeInterface returns immediately for it. Decoder.ignoreInterface instead unconditionally calls decodeTypeSequence(true). The shared function is selected for ignored interfaces inside slices, arrays, and maps and for whole-value discards, so repairing the discriminator there addresses the class rather than special-casing one container.

The native check stored on prop_prexjgb98q builds this checkout and runs `./bin/go test encoding/gob -run '^TestGobOmittedInterfaceProjectionProperty$' -count=1 -timeout=60s -v`. checkProperty run call_IohUbczx6FgedqiRRlHN9po8 at dcc06a82727b447270b1a58cc5f86b49736e317c exited 1 on attempt 29. Its reduced input is form=slice, tokens=[0] (nil), keep=1. The full-schema decode and following-message control succeeded before the projected Decode returned `gob: duplicate type received`, leaving retained fields unset. The run returned testdata/omitted_interface_projection/replay.json. The search stopped at the first failure; it did not complete its 11,200-case bound.

The smallest Case check is this replay plus an array control and a subsequent stream value. Establish that nil discard consumes only its name marker and preserves retained fields and stream alignment; extend to mixed nil/non-nil containers and whole-value discard to validate the shared repair. Non-nil interface and existing error behavior are regression controls. These suggested test forms are provisional proof methods, not additional repository-placement requirements.

The owner-specific prior searches returned no matching repair. The bounded GitHub open-PR scan has not yet reached its oldest page. Go's Gerrit archive was also searched for gob nil/ignore changes. Open https://go-review.googlesource.com/c/go/+/855461 adds nesting-depth accounting; its actual decode.go patch does not fix nil consumption. Merged https://go-review.googlesource.com/c/go/+/819481 returns encoder state after nil encoding, a distinct change already present in this checkout. The current upstream ignoreInterface implementation still performs the unconditional type-sequence read. Local history is shallow, and Gitiles/GitHub deeper history reads were refused; those remain evidence gaps. The supplied customer closures concern regexp scope or performance work and do not refute this gob mechanism.

Change to test: Treat the empty concrete-type name as a complete nil interface in the shared discard operation, without reading a type sequence or payload afterward. Preserve non-nil interface handling and add focused regression coverage for schema projection and stream alignment; the stored checker layout is provisional.

Where it lives

perfloop-oss/go · src/encoding/gob/decoder.go

Evidence

The check fails before this change and passes with it: `For valid gob structs whose omitted fields contain nil or mixed nil/non-nil interfaces in slices, arrays, maps, or nested structs, Decoder.Decode ignores those fields without losing retained fields or the next stream value.`

The check fails before this change and passes with it: `For valid gob nil interfaces and containers holding nil and non-nil interfaces, Decoder.Decode(nil) discards one value and preserves subsequent type definitions and stream alignment.`

Timeline