Repository navigation
Closed
Labels
area/literalsParse, TryParse and formattingarea/value-setsValue set families and wrapper aritiesbugSomething isn't workingpackage/coreAffects CodoMetis.ValueRangesseverity/criticalData loss, corruption, or silently wrong results in common use
Milestone
Description
Problem
A value set literal made of deeply nested braces overflows the stack, and .NET cannot catch a stack overflow, so the process dies. Found by the final pre-release analysis on origin/main add665c.
Int32Set.TryParse(new string('{', 50000) + new string('}', 50000), null, out _)crashes instead of returningfalse."{"*N + "1" + "}"*Ncrashes too: the walk recurses before it reaches the element.- Remotely triggerable. A Release Kestrel app with a minimal API taking
[FromHeader] Int32Setanswered 200 at depth 9,000 (an 18 KB header) and died with exit code 134 at depth 12,000 (24 KB, under Kestrel's default 32 KB header limit). Log:Stack overflow. at SetFormat.<IsNestOfEmptyArrays>g__Shape…. - Every set type, on every path that reaches
SetFormat.Parse: Parse/TryParse, the TypeConverter (MVC, configuration binding), minimal-API binding, and the EF JSON-column reader (by trace). Decorated literals ([1:1]=…) and multirange literals are safe; they were measured at 200k depth. - Where:
src/CodoMetis.ValueRanges/Internals/SetFormat.cs,IsNestOfEmptyArrays→ the recursive localShape. It came in with Value set literals refuse array_in's dimension decoration ([1:1]={…}) and {{}} #128 (Depth, cdba442), and fix: refuse a ragged nest of empty arrays in value set literals #240 kept the recursion. 9.1.0 does not have this code, so nothing that shipped is affected. - Measured on macOS: the main thread overflows between 10k and 50k levels, a thread-pool thread between 6k and 8k. Linux thread stacks were not measured.
Change
Make the walk iterative, or stop at depth 6, which is PostgreSQL's MAXDIM. The cap also fixes #250. Check every other recursive walk over untrusted literal text in src/ (range, multirange, element quoting) for the same shape.
Done when
Int32Set.TryParse of 100,000 nested braces returns false, and the same input through the TypeConverter and JSON is refused. A test over every discovered set type holds it in-process: it must not crash the test host, so bound the depth the test feeds. The fix commit carries Found-By: and Defect-Class: trailers.
Metadata
Metadata
Assignees
Labels
area/literalsParse, TryParse and formattingarea/value-setsValue set families and wrapper aritiesbugSomething isn't workingpackage/coreAffects CodoMetis.ValueRangesseverity/criticalData loss, corruption, or silently wrong results in common use
Activity