| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Could you add tests?
Sorry, something went wrong.
|
Added tests |
Sorry, something went wrong.
|
I pushed a minor test change to make the test run on both pure python and C encoder. |
Sorry, something went wrong.
|
@kumaraditya303 But the new tests don't reproduce the issue! |
Sorry, something went wrong.
This reverts commit 66c3af1.
I was able to reproduce it but now I can't, not sure if it was a build cache issue or something. Sorry reverted it back. |
Sorry, something went wrong.
Match the style of the comment added by pythongh-145244 for the dict iteration case. These explain why borrowed references from items lists and sequences must be held as strong references during encoding.
|
nothing the irony of my commit re-adding explanatory comments that earlier reviewer wanted removed. the other PR I merged intersecting with this region and bug had such a comment so put them in here as well. i'll re-look at the whole and pick a direction in a bit. |
Sorry, something went wrong.
- Replace bare try/except with direct calls; both tests should succeed without raising since encode_str and default return valid serializable values. - Assert that the mutation path was actually exercised (cleared flag, call_count). - Trigger list mutation on 3rd element instead of 1st, so the loop processes multiple items before the list is cleared mid-iteration. - Add comments explaining what each test verifies.
|
Sorry, @ashm-dev and @gpshead, I could not cleanly backport this to 3.14 due to a conflict. cherry_picker 235fa7244a0474c492ae98ee444529c7ba2a9047 3.14 |
Sorry, something went wrong.
|
Sorry, @ashm-dev and @gpshead, I could not cleanly backport this to 3.13 due to a conflict. cherry_picker 235fa7244a0474c492ae98ee444529c7ba2a9047 3.13 |
Sorry, something went wrong.
… mutation (pythongh-142851) Hold strong references to borrowed items unconditionally (not only in free-threading builds) in _encoder_iterate_mapping_lock_held and _encoder_iterate_fast_seq_lock_held. User callbacks invoked during encoding can mutate or clear the underlying container, invalidating borrowed references. The dict iteration path was already fixed by pythongh-145244. Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
@ashm-dev are you able to do the backports (see the bot's comments above for instructions)? |
Sorry, something went wrong.
|
@StanFromIreland Yes, of course I will |
Sorry, something went wrong.
|
GH-150078 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
|
GH-150079 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
|
@StanFromIreland backports done — manually because the bot couldn't cherry-pick cleanly (the iteration loops in 3.13/3.14 had not yet been extracted into the _encoder_iterate_*_lock_held helpers that exist in main):
Both built locally with --with-pydebug and test_json passes (both new UAF regression tests included). |
Sorry, something went wrong.
…t mutation (gh-142851) (#150078) gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) User callbacks invoked during JSON encoding (e.g. the `default` callback or a custom string encoder) can mutate or clear the dict or sequence being encoded, invalidating borrowed references to items, keys, and values. Hold strong references unconditionally while iterating. (cherry picked from commit 235fa72) Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Gregory P. Smith <greg@krypto.org>
…t mutation (gh-142851) (#150079) gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) User callbacks invoked during JSON encoding (e.g. the `default` callback or a custom string encoder) can mutate or clear the dict or sequence being encoded, invalidating borrowed references to items, keys, and values. Hold strong references unconditionally while iterating. (cherry picked from commit 235fa72) Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Gregory P. Smith <greg@krypto.org>
|
thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #142831