[python] Ensure GIL is held during CPython API call#22402
Merged
vepadulano merged 1 commit intoMay 27, 2026
Conversation
1 task
Test Results 22 files 22 suites 3d 12h 45m 1s ⏱️ Results for commit fc87fa7. ♻️ This comment has been updated with latest results. |
guitargeek
approved these changes
May 26, 2026
guitargeek
left a comment
Contributor
There was a problem hiding this comment.
Thank you very much for the fix!
ROOT's CPython extension defines a custom error handler that tries to use Python standard warnings when possible. In such cases, the CPython API is called and thus the GIL must be held. If the calling Python function had previously released the GIL it will result in trouble. This is the case for the TH1.Fit method which has been changed to always releasing the GIL, under the assumption that everything happening during the call happens in C++, but that's not true. This commit proposes to restore the GIL for the call to the CPython API to raise the warning.
39eeb7d to
fc87fa7
Compare
Member
Author
|
/backport to 6.40 |
|
Preparing to backport PR #22402 to branch 6.40 requested by vepadulano |
|
This PR has been backported to branch 6.40: #22408 |
11 tasks
wdconinc
added a commit
to eic/eic-spack
that referenced
this pull request
Jun 3, 2026
### Briefly, what does this PR introduce? Please link to any relevant presentations or discussions. This PR backports root-project/root#22402 into 6.38.02 through 6.40.00, in order to avoid failures in https://eicweb.phy.anl.gov/EIC/benchmarks/detector_benchmarks/-/jobs/7889057. ### What is the urgency of this PR? - [ ] High (please describe reason below) - [x] Medium - [ ] Low ### What kind of change does this PR introduce? - [x] Bug fix (issue: https://eicweb.phy.anl.gov/EIC/benchmarks/detector_benchmarks/-/jobs/7889057) - [ ] New feature (issue #__) - [ ] Optimization (issue #__) - [ ] Updated documentation - [ ] other: __ ### Please check if any of the following apply - [ ] This PR introduces breaking changes. Please describe changes users need to make below. - [ ] This PR changes default behavior. Please describe changes below. - [ ] AI was used in preparing this PR. Please describe usage below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ROOT's CPython extension defines a custom error handler that tries to use Python standard warnings when possible. In such cases, the CPython API is called and thus the GIL must be held. If the calling Python function had previously released the GIL it will result in trouble. This is the case for the TH1.Fit method which has been changed to always releasing the GIL, under the assumption that everything happening during the call happens in C++, but that's not true. This commit proposes to restore the GIL for the call to the CPython API to raise the warning.