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
JSON crashes during encoding resized lists #60432
Comments
JSON encoding crash if the source list resized in process of encoding. This can be happen unintentionally in multithreaded code. Simple crash code: import json
a = [object()] * 10
def crasher(obj):
del a[-1]
json.dumps(a, default=crasher) |
Here is a patch. |
The patch LGTM except I cannot reproduce crash on unmodified sources with running applied test. |
Of course, this kind of bugs can cause unpredictable behavior, they do not have to lead to an immediate crash. This depends from the platform, the compiler and its options. On my computers the test always crashed, this is the maximum that I can say. |
New changeset 3672db224eb3 by Antoine Pitrou in branch '3.2': New changeset 7528c02b8d52 by Antoine Pitrou in branch '3.3': New changeset ab65509b8443 by Antoine Pitrou in branch 'default': |
New changeset 33ae62a4ecf5 by Antoine Pitrou in branch '2.7': |
Thank you for noticing this, and for writing a patch. |
Hi, I'm ok with patch but I guess to add some comment in C code to prevent, hmm, back optimization from upcoming contributor. |
But that's what tests are for. |
As I said tests was not crashed on my linux 64 bit Ubuntu with buggy code. |
They crashed duly here in debug mode (64-bit Linux). |
I have python built with Py_DEBUG (./configure --with-pydebug) |
Well, I don't know. Perhaps a different compiler version, a different |
Ok. Thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: