Skip to content

Bound the text the fuzz comparison builds for a value - #512

Open
dimensionscape wants to merge 1 commit into
mainfrom
fix/fuzz-canon-text
Open

dimensionscape wants to merge 1 commit into
mainfrom
fix/fuzz-canon-text

Conversation

@dimensionscape

Copy link
Copy Markdown
Member

The scheduled fuzz run of 2026-11-30 (run 46464537090) stopped in the serializer target with libFuzzer: out-of-memory (used: 4185Mb; limit: 4096Mb). Loading the 3,881 cached inputs had already taken RSS from 115 MB to 3472 MB at 9 inputs a second. ASan counted 88 MB live, and the large stacks were all canon() in test/fuzz/Fuzz.hx concatenating strings. The input it stopped on, Moy0:r0gr0h..., is an ObjectMap whose key, an object, and value both hold the map.

canon() stops after 100,000 steps, but in such a map the text also grows about 1.6 times a level, and each level copies the texts below it. That input built 20 million characters before it ran out of steps. With a 3,000 character string beside the key's reference it built 720 million, which took 850 MB and 8 s under ASan, and mutants of it reached 1.3 GB and 23 s. None of them was compared in the end, since each ran out of steps.

canon() now also gives up after 4,194,304 characters, counting each level's text as it is built, so it allocates at most a few times that for a value. Without references or runs of nulls, 4096 bytes of input build under a third of it. A value past it is not compared, like one past the step limit; 99,000 nulls 32 levels down (16 million characters) was compared before and is not now. Values that fit compare as before.

The CI input goes in test/fuzz/regressions/serializer.

Checked with clang 18, ASan and UBSan in WSL:

main this change
The CI input 214 MB, 0.7 s 167 MB, 0.24 s
With a 3,000 character string beside the reference 849 MB, 8.4 s 175 MB, 0.16 s
A mutant of that 1.3 GB, 23 s 189 MB, 0.14 s
Loading 3,392 serializer inputs from local runs 620 s and 1.4 GB, then a 20 s timeout 158 s, 750 MB
30 minutes from there, 78,263 inputs 760 MB throughout

Every target replays its seeds and regressions. Test-only, so no Changes.md line.

The scheduled fuzz run of 2026-11-30 stopped in the serializer target
with libFuzzer's out-of-memory error, 4185 MB against its 4096 MB limit.
Loading the 3,881 cached inputs had already taken it from 115 MB to
3472 MB at 9 inputs a second. ASan counted 88 MB live, and the large
stacks were all canon() concatenating strings. The input it stopped on,
"Moy0:r0gr0h...", is an ObjectMap whose key, an object, and value both
hold the map.

canon() stops after 100,000 steps, but in such a map the text also
grows about 1.6 times a level, and each level copies the texts below
it. That input built 20 million characters of text before it ran out of
steps; with a 3,000 character string beside the key's reference, 720
million, which took 850 MB and 8 seconds under ASan, and mutants of it
up to 1.3 GB and 23 seconds. None of them was compared in the end,
since each ran out of steps.

canon() now also gives up after 4,194,304 characters, counting each
level's text as it is built, so it allocates at most a few times that
for a value. Without references or runs of nulls, 4096 bytes of input
build under a third of it. A value past it is not compared, as one past
the step limit already was; 99,000 nulls 32 levels down, which builds
16 million characters, was compared before and is not now.

Tests: the input is in test/fuzz/regressions/serializer. With clang 18,
ASan and UBSan in WSL, every target replays its seeds and regressions,
and the inputs above take 167 to 189 MB and under 0.3 seconds each.
Loading 3,392 serializer inputs that local runs gathered took main 620
seconds and 1.4 GB before a 20-second timeout, and this change 158
seconds and 750 MB. From there a 30-minute run of 78,263 inputs stayed
at 760 MB throughout.
@dimensionscape dimensionscape added this to the 6.1.0 milestone Dec 1, 2026
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