-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix segfaults on tests in debug builds for PyPy #744
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #744 +/- ##
=======================================
Coverage 93.63% 93.63%
=======================================
Files 99 99
Lines 13895 13895
Branches 25 25
=======================================
Hits 13010 13010
Misses 879 879
Partials 6 6
Continue to review full report in Codecov by Sentry.
|
CodSpeed Performance ReportMerging #744 will improve performances by 12.51%Comparing Summary
Benchmarks breakdown
|
Thank you! I can confirm that with this patch added, the tests no longer crash for me. |
33ee071
to
ba938b7
Compare
ba938b7
to
7e8a88d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I noticed the other day is that this limit gets hit if you just nest a bunch of function validators, e.g.
schema = int_schema()
for _ in range(1000):
schema = no_info_after_validator_function(lambda x: x, schema)
Not something we need to fix here, but just food for thought.
Yes, I think the best thing to consider would be that we make the recursion limit configurable. This is just a best-effort thing to protect users from segfaults on stack overflow, so if they think they have more stack space they could increase our limit safely. Either we could make our limit configurable, or potentially we could use |
Change Summary
This PR unifies the recursion guard limit between serialization and validation to 255 (thanks @adamreichold for the suggestion to move to a single limit).
I also add
pytest.skip
to a few tests which fail on PyPy with debug builds. This is because Rust debug builds don't optimize their stack space, so we hit trivial stack overflows.Finally I add a
test-debug
job for PyPy 3.9 - can bump to PyPy 3.10 once the upstream PyO3 bug is fixed.Related issue number
Ref #659
This should avoid crashes on debug builds with PyPy. (Doesn't close the full issue, which also exposes a bug in PyO3.)
Checklist
pydantic-core
(except for expected changes)