-
Notifications
You must be signed in to change notification settings - Fork 85
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
Fix tests for libexpat >=2.6.0 (or with CVE-2023-52425 fixes backported) #556
Conversation
Quick update on CPython: All related backport pull requests have now been merged. The next step is CPython security releases and then distros picking them up. Regarding related expected releases dates, so far I only found:
|
@thiell by any chance do you know if the issue I'm fixing for the tests here affects the core ClusterShell software also? Is it just the tests that break with Expat >=2.6.0 or more? |
PS: These three are out since yesterday March 19, 2024: |
@thiell any chance for a reply this week? We'll have to make decision in Gentoo whether to stabilize libexpat >=2.6.0 or not for all users, and knowing if core ClusterShell is affected outside the tests is the last missing piece in the picture, before making a decision. Thanks in advance, have a good start to the week 🍻 |
@hartwork When ClusterShell is configured to use the tree execution mode, the communication protocol with the remote ClusterShell gateway(s) uses XML and we parse it incrementally with an A question I have is does the issue only occur with multithreaded codes? The test case uses two threads for example to simulate a remote gateway. In |
@thiell thanks for your detailed reply! 👍 The way I read the linked code, clustershell/lib/ClusterShell/Communication.py Lines 254 to 258 in ec8be76
To me, it looks like the parser can just have its pace and the receivers need to be okay with any rate. If that's reality, it probably means that there is no problem with an occasional delay in events? With regard to multi-threading, my understanding is that it's technically not the two threads but their blocking lockstep relationship that breaks with Expat >=2.6.0: every parser feed was expected to produce events immediately by the test code. The fix to CVE-2023-52425 in Expat can add delay to creation of events — firing of handlers in the language of Expat — depending on how big or small input chunks get, and that made one thread wait for an event that would not be produced without further input. Maybe a good stress test would be to turn…
…into a loop feeding single bytes to make things worst (and be reverted), and running that with Expat >=2.6.0, if someone gets a chance to. What do you think? PS: On a side note Expat is not thread-safe and multi-threaded access would need synchronization around it, likely even from Python code (python/cpython#62170), not just in C. (I'm in favor of considering that a bug in CPython.) |
Released by now on 2024-04-02 — https://docs.python.org/release/3.11.9/whatsnew/changelog.html#python-3-11-9
Released by now on 2024-04-09 — https://docs.python.org/release/3.12.3/whatsnew/changelog.html#python-3-12-2 |
b4deef1
to
5519f04
Compare
@thiell I would expect CI on master to fail by now because it has |
Thanks for the clarification. That's fine in our case as we communicate through pipes.
Actually, I noticed some random hung tests, that I relaunched manually. I just added support for testing with Python 3.12 too, and I saw a hung test. I think this is likely related to this issue. I reviewed your proposed changes and I am ok to merge them as a first step. Note that I personally don't love the additional Now apart from this test, I think we could have some problems with delayed events in the parser when used in clustershell's tree mode: XML is parsed incrementally between cluster nodes and the connection might be established for a long time between then, triggering events when they arrive. The source XML is generated by clustershell itself, so I think it would be fine in terms of security to just disable this reparse deferral feature with SetReparseDeferralEnabled(false) if available. Sorry to be a bit slow but thanks for your help with this! |
Use SetReparseDeferralEnabled() API to restore previous bahavior as we control the source of the XML.
@hartwork Ah, interestingly, it looks like the incremental SAX parser that we use (
|
This is due to libexpat 2.6 reparse deferral as documented in cea-hpc#556. Unfortunately ExpatParser doesn't seem to have SetReparseDeferralEnabled(), so we use an explicit flush() call to make sure all handlers are called immediately. We control the source XML. NOTE: Only available in Python 3.13 and backports.
@thiell correct, the description of python/cpython#115623 has the list of all related methods added (and to which class). The involved classes are quite different and there was not much room for how to implement things in CPython.
Correct, there is no such method in that class. Could you summarize status and plans for the new pull request #569? That would be great! |
This is due to libexpat 2.6 reparse deferral as documented in #556. Unfortunately ExpatParser doesn't seem to have SetReparseDeferralEnabled(), so we use an explicit flush() call to make sure all handlers are called immediately. We control the source XML. NOTE: Only available in Python 3.13 and backports.
Hi! 👋
It was reported that the clustershell test suite breaks with Expat >=2.6.0 (https://bugs.gentoo.org/924601). So this pull request fixes the test suite for Expat >=2.6.0 with CPython 3.13 and backport releases by using the new pyexpat API (python/cpython#115398). There is no rush in merging this, we can definitey wait for that APi to become more widely available if you like, it will likely appear in these very CPython releases:
I should note that Python 3.7 and earlier are dead, hence related pull request #555.
I'm looking forward to your review, maybe I missed something 🍻
Best, Sebastian