Fix Python ownership transfer to LCIO containers - #226
Open
jmcarcell wants to merge 1 commit into
Open
Conversation
jmcarcell
force-pushed
the
fix-python-container-ownership
branch
from
September 8, 2026 06:57
3409865 to
fba0607
Compare
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.
BEGINRELEASENOTES
ENDRELEASENOTES
pyLCIO exposes the legacy LCIO ownership-transfer APIs directly through cppyy.
LCCollectionVec::addElement(LCObject*)andLCEventImpl::addCollection(LCCollection*, ...)store raw pointers, but their Python proxies remain Python-owned. Python can therefore delete an object still referenced by an LCIO container.The crash can be seen in the key4hep build workflow (https://github.com/iLCSoft/LCIO/actions/runs/34105308165/job/101688847377). I can reproduce it:
The crash is before the handler makes its first SIO call: it is the
dynamic_castof a danglingLCObject*. Retaining Python proxies lets writing complete but then crashes during CPyCppyy proxy destruction, confirming double ownership.This looks likely to have been a long-standing ownership bug. The move of the nightlies to the LCG stacks likely exposed it through the current cppyy and Python 3.13 runtime.