TChain broken in python
Check duplicate issues.
- [ ] Checked for duplicates
Description
ROOT version 6.32.00 built for linuxx8664gcc breaks pythonized TChain access that worked in version 6.26/14 built for linuxx8664gcc. Now, accessing TBranches in a TChain causes a segmentation fault when switching from first file to the next file.
The essential code that replicates this bug in ROOT 6.32.00 appears below. The stack trace is attached.
Is there a workaround? I tried numerical index loop through the TChain entries with chain.GetEntry(index) and then python access to the branches via getaddr() but this caused the same segfault.
Reproducer
Here is test.py.
#!/usr/bin/env python3
import ROOT
from ROOT import TChain, TFile
def main():
fileChain = TChain('tree')
fileChain.Add('file1.root')
fileChain.Add('file2.root')
processEvents(fileChain)
def processEvents(fileChain):
treeNumber = -999
for entry in fileChain:
treeNo = fileChain.GetTreeNumber()
if treeNo != treeNumber:
treeNumber = treeNo
print('Tree Number ', treeNumber)
branch = entry.MyBranch # <-- segfault happens here as soon as tree number changes from 0 to 1
####################################################################
# Entry point of this script: call the main() function #
####################################################################
if __name__ == '__main__':
main()
ROOT version
------------------------------------------------------------------
| Welcome to ROOT 6.32.00 https://root.cern |
| (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on May 08 2025, 22:46:23 |
| From heads/v6-32-patches@tags/v6-32-00 |
| With g++ (GCC) 14.2.0 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Installation method
Build from source
Operating system
Linux cw01.cc.kek.jp 5.14.0-362.8.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Oct 3 11:12:36 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
Additional context
No response
Dear @piilonen ,
Thanks for reaching out! I'm sorry this stopped working. There have been many, many improvements between 6.32.00 and the most recently released version 6.36.00. The issue you report sounds vaguely related to others I have seen in the past. While I search for that, I wonder if you could attempt to reproduce your problem with a more recent version of ROOT?
Cheers, Vincenzo
Could you try with https://root.cern/releases/release-63212/ ?
Alternatively, can you share file1.root and file2.root ?