Skip to content

Reject top-level single-value decoding#331

Merged
dduan merged 1 commit into
mainfrom
codex/fuzzing-infrastructure
Jul 10, 2026
Merged

Reject top-level single-value decoding#331
dduan merged 1 commit into
mainfrom
codex/fuzzing-infrastructure

Conversation

@dduan

@dduan dduan commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Reject single-value decoding requests when the decoder is wrapping a top-level TOML table.
  • Return a DecodingError.typeMismatch instead of attempting to unpack an uninitialized token.
  • Add a Swift Testing regression for decoding a top-level table as Int.

Root cause

A top-level TOMLDecoder wraps a keyed TOMLTable and leaves its scalar token at the empty sentinel. When a scalar Decodable type requested a single-value container, the decoder returned itself and integer decoding indexed that empty token range, producing a SIGTRAP during decoder-fuzzer corpus initialization.

Impact

Wrong-shape top-level decoding now fails normally with DecodingError instead of terminating the process. This allows the decoder fuzz target to load valid table-shaped corpus entries and continue fuzzing.

Validation

  • swift test — 750 tests passed.
  • swift test --filter TOMLDecoderTests.topLevelTableCannotDecodeAsSingleValue
  • Decoder libFuzzer startup corpus replay — 217 inputs passed without trapping.
  • Multi-worker decoder fuzzing completed without crash artifacts.

@dduan dduan marked this pull request as ready for review July 10, 2026 17:40
@dduan dduan enabled auto-merge (squash) July 10, 2026 17:40
@github-actions

Copy link
Copy Markdown

�[33mWarning: running with the Swift runtime interposer on Linux to avoid the Swift 6.3 runtime hook crash. See https://github.com/ordo-one/benchmark/issues/349�[0m

Comparing results between 'main' and 'pull_request'

Host 'runnervm5mmn9' with 4 'x86_64' processors with 15 GB memory, running:
#18~24.04.1-Ubuntu SMP Thu May 28 16:39:11 UTC 2026

TOMLDecoderBenchmarks

Decode toml.io example metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (μs) * p0 p25 p50 p75 p90 p99 p100 Samples
main 64 64 65 67 72 101 171 7150
pull_request 62 64 64 65 70 96 191 7240
Δ -2 0 -1 -2 -2 -5 20 90
Improvement % 3 0 2 3 3 5 -12 90

Retains: results within specified thresholds, fold down for details.

Retains * p0 p25 p50 p75 p90 p99 p100 Samples
main 765 765 765 765 765 765 765 7150
pull_request 765 765 765 765 765 765 765 7240
Δ 0 0 0 0 0 0 0 90
Improvement % 0 0 0 0 0 0 0 90

Parse toml.io example metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (ns) * p0 p25 p50 p75 p90 p99 p100 Samples
main 5100 5243 5283 5323 5451 7435 34925 10000
pull_request 5029 5143 5171 5211 5271 7287 37250 10000
Δ -71 -100 -112 -112 -180 -148 2325 0
Improvement % 1 2 2 2 3 2 -7 0

Retains: results within specified thresholds, fold down for details.

Retains * p0 p25 p50 p75 p90 p99 p100 Samples
main 31 31 31 31 31 31 31 10000
pull_request 31 31 31 31 31 31 31 10000
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

decode canada.toml metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (ms) * p0 p25 p50 p75 p90 p99 p100 Samples
main 256 256 257 261 261 261 261 4
pull_request 256 256 257 261 263 263 263 4
Δ 0 0 0 0 2 2 2 0
Improvement % 0 0 0 0 -1 -1 -1 0

Retains: results within specified thresholds, fold down for details.

Retains (K) * p0 p25 p50 p75 p90 p99 p100 Samples
main 1286 1286 1286 1286 1286 1286 1286 4
pull_request 1286 1286 1286 1286 1286 1286 1286 4
Δ 0 0 0 0 0 0 0 0
Improvement % 0 0 0 0 0 0 0 0

decode twitter.toml metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (μs) * p0 p25 p50 p75 p90 p99 p100 Samples
main 9093 9921 10002 10060 10150 10546 10546 99
pull_request 8688 9404 9429 9478 9544 9789 10106 106
Δ -405 -517 -573 -582 -606 -757 -440 7
Improvement % 4 5 6 6 6 7 4 7

Retains: results within specified thresholds, fold down for details.

Retains (K) * p0 p25 p50 p75 p90 p99 p100 Samples
main 113 113 113 113 113 113 113 99
pull_request 113 113 113 113 113 113 113 106
Δ 0 0 0 0 0 0 0 7
Improvement % 0 0 0 0 0 0 0 7

parse GitHub events archive metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (ms) * p0 p25 p50 p75 p90 p99 p100 Samples
main 129 130 131 134 141 141 141 8
pull_request 120 121 121 125 133 133 133 9
Δ -9 -9 -10 -9 -8 -8 -8 1
Improvement % 7 7 8 7 6 6 6 1

Retains: results within specified thresholds, fold down for details.

Retains (K) * p0 p25 p50 p75 p90 p99 p100 Samples
main 394 394 394 394 394 394 394 8
pull_request 394 394 394 394 394 394 394 9
Δ 0 0 0 0 0 0 0 1
Improvement % 0 0 0 0 0 0 0 1

parse canada.toml metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (ms) * p0 p25 p50 p75 p90 p99 p100 Samples
main 16 16 16 16 16 23 23 62
pull_request 15 15 15 15 15 23 23 66
Δ -1 -1 -1 -1 -1 0 0 4
Improvement % 6 6 6 6 6 0 0 4

Retains: results within specified thresholds, fold down for details.

Retains * p0 p25 p50 p75 p90 p99 p100 Samples
main 47 47 47 47 47 47 47 62
pull_request 47 47 47 47 47 47 47 66
Δ 0 0 0 0 0 0 0 4
Improvement % 0 0 0 0 0 0 0 4

parse twitter.toml metrics

Time (wall clock): results within specified thresholds, fold down for details.

Time (wall clock) (μs) * p0 p25 p50 p75 p90 p99 p100 Samples
main 2339 2367 2386 2402 2427 2591 3547 406
pull_request 2196 2222 2230 2243 2271 2929 3510 434
Δ -143 -145 -156 -159 -156 338 -37 28
Improvement % 6 6 7 7 6 -13 1 28

Retains: results within specified thresholds, fold down for details.

Retains * p0 p25 p50 p75 p90 p99 p100 Samples
main 7736 7736 7736 7736 7736 7736 7736 406
pull_request 7736 7736 7736 7736 7736 7736 7736 434
Δ 0 0 0 0 0 0 0 28
Improvement % 0 0 0 0 0 0 0 28

@dduan dduan merged commit 30d03ac into main Jul 10, 2026
16 checks passed
@dduan dduan deleted the codex/fuzzing-infrastructure branch July 10, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant