Repository navigation
🐛 fix(validate): raise MemoryError when schema allocation fails - #2177
Merged
Merged
Conversation
A schema that runs out of memory while it compiles can report the wrong error. Every arena allocation failure leaves a partial build behind, so a name that could not be resolved produced "does not resolve" or "root element is not an xs:schema", and callers got a ValueError instead of MemoryError. Validation checked the choice limit and the pattern budget before the arena flag, so a lost allocation after either limit tripped was reported as an ambiguous content model or an exhausted budget. The arena flag now decides at both entry points, before any error the partial build raised. The choice limit no longer sets the arena flag, so a limit trip and an allocation failure stay distinct. The allocation-failure sweep now expects MemoryError on every path it reaches.
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Fixes #2171.
Running out of memory while compiling or validating an XML Schema or RELAX NG schema could surface as a
ValueErrorabout the schema or about a validation limit. The message named the wrong cause, so callers that handle aMemoryErrornever saw the shortage. 🧠 Both entry points now raiseMemoryErrorwhenever an allocation fails.The schema arena records a lost allocation in one flag. Compilation and validation now check that flag before they report any error or limit, because an error or limit reached after a lost allocation is a symptom of that loss. The choice limit and the pattern budget keep their own
ValueErrors and no longer set the out-of-memory flag, so the two causes stay separate.Behavior changes
XMLSchema(...),RelaxNG(...), or theirvalidate()calls raisesMemoryError, where it could raiseValueErrorbefore.ValueErrorwhen they are reached without an allocation failure.