fix format error that leads to segfaults#1310
fix format error that leads to segfaults#1310Vizonex wants to merge 18 commits intoaio-libs:masterfrom
Conversation
|
Fix looks good. Can you add a test? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1310 +/- ##
=======================================
Coverage 99.85% 99.85%
=======================================
Files 26 26
Lines 3513 3539 +26
Branches 253 254 +1
=======================================
+ Hits 3508 3534 +26
Misses 3 3
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
There was a problem hiding this comment.
Pull request overview
Fixes a user-triggerable crash during MultiDict construction from an update sequence when an element’s __getitem__ fails, by correcting the C extension error formatting and adding a regression test (with a matching behavior tweak in the pure-Python implementation).
Changes:
- Fix swapped
PyErr_Formatarguments in_err_cannot_fetchto prevent invalid pointer formatting/segfaults. - Add a regression test covering an update-sequence element whose
__getitem__raises. - Update the pure-Python argument parsing path to raise a consistent
ValueErrorwhen element indexing fails.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_multidict.py | Adds regression test for failing __getitem__ during construction. |
| multidict/_multilib/hashtable.h | Fixes _err_cannot_fetch format argument order to prevent crash. |
| multidict/_multidict_py.py | Wraps item indexing failures into a ValueError for consistency with C extension. |
| CHANGES/1310.bugfix.rst | Adds changelog note for the crash fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
stall in test_cannot_create_from_item_with_failing_getitem[c-cls0] |
What do these changes do?
This was based off a user-accessible segfault found by @devdanzin. Not sure how this appeared out of nowhere but my best assumption it could've been caused by developer fatigue or burn out. The reproducible seen in this gist here https://gist.github.com/devdanzin/a36588ae7e2b73f0d85f8a925fb13b3d is not just limited to 3.14 but also 3.10 (which I have now recently tested myself) so I've gone ahead and fixed it. Feel free to let me know if this should somehow be added to pytest although IDK where to put it. Originally was going to write this off as an ffmpeg fiasco but this does not seem to be the case. Seems we might have couple of other sneaky bugs to patch.
Reproducer from the gist brought here for reference
Are there changes in behavior for the user?
Related issue number
Note
This does not close this issue as there is still other information about other bugs that have yet to be patched.
#1306
Checklist