Repository navigation
[v640][Python] Fix crash unpickling a ROOT object without importing cppyy - #22975
Merged
Merged
Conversation
Unpickling a ROOT object resolves its reduce callable `ROOT.libROOTPythonizations._CPPInstance__expand__`, which only imports the ROOT pythonizations extension and not the cppyy backend. It then enters CPyCppyy through the public API (Instance_FromVoidPtr) to rebuild the object. In that state, `CPyCppyy::Initialize()` only imported the cppyy module in the branch taken when Python was not yet initialized. When Python is already running (the normal unpickling case), that branch is skipped and `Initialize()` returned success without ever importing cppyy, leaving gThisModule null. `CreateScopeProxy()` then dereferenced it as a fake scope and crashed with a segmentation violation. Ensure the cppyy extension module is imported whenever `gThisModule` is still null, so the public API is usable regardless of how CPyCppyy was entered. Add a regression test that pickles a ROOT object and reads it back in a fresh interpreter where cppyy has not been imported yet. 🤖 Done with the help of AI. (cherry picked from commit f2e0f52)
guitargeek
merged commit Jul 31, 2026
442e832
into
root-project:v6-40-00-patches
33 of 34 checks passed
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.
Backport of: