Enforce recursion limit for serde Content enum variants #632
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 181 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.311
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #632"
general
weight: 0.35
juntyr
Recursion limit bypass for enum variants inside serde
ContentWhen deserialising into serde's
Content(untagged enums, etc.),handle_any_structhands anIdent(...)variant tovisit_map(SerdeEnumContent { .. }), and the newtype branch recurses throughself.deserialize_any. Neither goes throughguard_recursion!, soA(A(A(...)))never hitsOptions::recursion_limit. Each level also runs the O(N)TupleMode::DifferentiateNewtypelookahead, so parse time grows quadratically with depth, and at a few thousand levels the process aborts with a stack overflow (not catchable as a panic). Both calls are now guarded, giving each level the same cost as the typed path (deserialize_enum+newtype_variant_seed).#[serde(untagged)] enum U { Unit(()) }, input"A(".repeat(n) + "()" + ")".repeat(n), release build:| depth | input | before | after |
|---|---|---|---|
| 256 | 770 B | 3.9 ms | 1.6 ms,
ExceededRecursionLimit|| 512 | 1.5 KB | 15.0 ms | 4.0 ms,
ExceededRecursionLimit|| 1024 | 3 KB | 57.5 ms | 6.7 ms,
ExceededRecursionLimit|| 1536 | 4.6 KB | stack overflow, abort | 9.2 ms,
ExceededRecursionLimit|The new test in
tests/307_stack_overflow.rsaborts with a stack overflow on master and passes with the fix.cargo test --all-targetspasses with default features,integer128,indexmapand--all-features, andcargo fmt --checkis clean.CHANGELOG.md