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
Mutlithread XML parsing cause segfault #62170
Comments
Linux i386, Python 2.7.4. Multithread xml parsing via pyexpat cause segmentation fault |
Expat is not thread-safe at the object level, a single Parser cannot be used from multiple threads. |
It could also track tids and raise an error if you attempt to use it from multiple threads. |
But this would break working code which already uses locks correctly (or some kind of pool of cached parsers) |
In my opinion it's fine to document Python's XML parser as not thread-safe and leave locking to the user. Any fancy locking or tracking is going to make it slower for users. Any it takes a lot of effort to implement the feature, too. lxml offers a faster XML parser with multi-threading support. |
In my opinion it's not fine to let Python crash. |
I agree with Amaury, multi-threaded parsing should definitely not crash. Adding a lock should be quite easy. I wonder what would be the effect on performance, if there are lots of backs and forths between expat and Python. |
I've reproduced the segfault on 3.11. |
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: