Files
Marc fbd204bcb9 Make the encoder stack-depth tests hold on a reused thread stack
DecodeWithUnboundedNestingLimitFailsBeforeTheStackOverflows(Json, VariantArray)
and (Json, DataValue) failed intermittently on Linux CI: the 450-level JSON
input decoded without tripping the stack check.

A thread that asks for a 256 KB stack can run on more. glibc reuses the cached
stack of an exited thread when it is at most four times the requested size,
and this fixture's own 1 MB threads leave such stacks behind. The stack check
measures the stack the thread got, and 450 JSON levels fit a 1 MB stack.
Running a 1 MB thread right before the decode reproduces the failure on
Linux 20 times out of 20; Windows does not reuse stacks this way.

The unbounded-limit tests now run on the 1 MB and the 256 KB stack and nest
5000 levels, twice the deepest nesting of any codec and shape that fits a
1 MB stack (2477 levels: JSON EncodeableTree, Linux, Release). The 2000
levels of the other codecs were too few as well: on Linux, encoding a Binary
EncodeableTree of 2000 levels fits a 1 MB stack. The JSON input is written
by hand because the JsonEncoder cannot nest deeper than 1000 levels, and
NestedJsonMatchesTheJsonEncoder keeps it equal to the encoder's output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-09 16:18:14 +02:00
..