Repository navigation
feat(events): run bounded checks on large-stack threads and set the nesting limit to 64 - #653
Merged
Merged
Conversation
JuroOravec
force-pushed
the
feat/bounded-checks-large-stack
branch
from
November 14, 2026 14:12
d248b45 to
4dea6cc
Compare
…esting limit to 64 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lures A check thread no longer keeps the last job's call, context or result after the caller has them, a failure in the thread's own loop is logged and leaves an outcome that was already set, and a failed reset of the thread stack size is logged. Tests cover each, plus a render with plain nested data from a small thread and a handler writing out data at the limit on a 512 KiB thread. Docs give the measured hand-over time and say what a slow validator does to the pool. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing caller Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
feat/bounded-checks-large-stack
branch
from
November 14, 2026 14:23
8b10ece to
3754ba0
Compare
JuroOravec
added a commit
that referenced
this pull request
Nov 14, 2026
…ight merged changes (#682) Add one record under docs/security/reviews/ for each of the eight published 0.8.0 advisories (GHSA-4hj5, -8xvf, -7qpw, -g658, -x6rm, -h524, -xmx5, -xg8c) and for each of the pull requests that Mechanism 7, step 7 owes one: #610, #640, #651, #652, #653, #658, #674 and #675. Each record says only what the public pull request, the published advisory, the merged code and its tests show, and lists what was not checked. The reviews README describes how a record for a published advisory differs from a pull request record. The Mechanism 7 list in CLAUDE.md gains the two places that GHSA-7qpw added: parser rules browsers differ on, and the page's declared encoding. Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Events checks event data, browser writes to State, and State read back from its token with Pydantic. Each nested level of data takes room on the stack of the thread that runs the check, so until now the nesting limit had to fit the smallest thread stack a server might use, and it was 32.
This PR runs those checks on a small set of threads that Citry starts itself, each with a 16 MiB stack. The nesting limit now does not depend on the server's thread stack size, and it rises to 64.
run_on_check_threadincitry/ext/events/_pydantic_bounded.pyhands a check to one of up to 32 threads, keeps two idle, and ends the others after 60 seconds without work. A check past 32 waits in a queue. Payload checks, State restore, State writes from the browser, writing State out for its token, comparing State a handler changed, and building and type-checking State for a render all go through it. A check that is already on a check thread runs at once._threadfunctions, whether the patching happened before or after Citry was imported, so a check always gets a real OS thread with its own stack.model_dump()on a chain of models fits about 100 levels in 512 KiB and about 22 in 128 KiB. The docs and changelog advise giving request threads at least 512 KiB.Upgrade note
App validators, State serializers and
__post_init__methods now run on Citry's threads. They can read the request's context variables, butthreading.localvalues are unset there, and a Django query from a validator uses that thread's own connection. The changelog has an "Upgrading from 0.8.x" section for this, anddocs_site/content/security.mdhas the details.Tests
tests/test_events_pydantic_bounded.pypasses (206 tests). ruff passes, and mypy passes for both darwin and--platform linux. CI will show the Linux and Windows results.🤖 Generated with Claude Code