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
XincludeTest failure in test_xml_etree #59280
Comments
The XincludeTest test-case in test_xml_etree is now skipped, because it fails in an intermittent manner. I can reproduce the failure when running full regrtest with -j1, but not -j8, and not when run individually. The failure is most likely due to the test itself, in the way it imports the Python ET, leaving _elementtree out. This may be related to http://bugs.python.org/issue14035 |
After some tinkering I found which test when run before test_xml_etree causes it to crash: $ ./python -m test.regrtest test___all__ test_xml_etree
[1/2] test___all__
[2/2] test_xml_etree
Fatal Python error: Segmentation fault Current thread 0x00007f771ecec700: Note that this is the Python test crashing. test_xml_etree_c works fine |
As suspected, the cause is that xinclude_loader manages to somehow import the C version of ET, although test_xml_etree tries to enforce the Python version. This is probably because test___all__ imports all modules and leaves stuff in the import cache. What causes the segfault itself is that C Elements are mixed with Python Elements, and they're incompatible. |
Here is a patch that solves the current problem. A longer term solution would be to have a cleaner test plan for ET in general, without monkey-patching at all, and without state that causes test-order dependencies. |
New changeset 5782efaa8d68 by Eli Bendersky in branch 'default': |
Opened bpo-15083 to track the *actual* solution to this problem, which should restructure the tests to be safer. |
Even if the ET tests are hacking sys.modules, I assume that the Python interpreter should not crash so badly. I suggest to re-open this to track the Segmentation fault. |
No need, the cause for the segfault is known. What happens is that Element objects from the Python module get intermixed with Element objects from the C module, and these are incompatible. The C module traversal functions assume they can cast Elements to a known structure (ElementObject), and when they get the invalid Elements they crash. Adding runtime checks everywhere is too costly. This situation cannot arise in a valid way. |
If runtime checks are needed to prevent mixing arbitrary objects into the tree, then I don't think they should be considered too costly. I agree with Florent that this is worth reopening. It doesn't look like a "Tests" bug to me rather a "Lib"/"XML" bug. |
I investigated a bit, and type checks were added to protect from such mixing. Please open a new patch with a speficic reproducer if you run into similar problems (interepreter crash). |
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: