Skip to content

Pyroot crashes reading TClonesArray in a TTree #16725

@AlexFinch

Description

@AlexFinch

Check duplicate issues.

  • Checked for duplicates

Description

A pyroot python program crashes when reading a TFile containing a TTree containing a TClonesArray. It appears to crash the second time it accesses the TClonesArray. This has started happening since moving to ROOT 6.32 on AlmaLinux 9.4. It worked fine with 6.20.04 running on Centos7. The library for accessing the TTree information was created using MakeProject.

Reproducer

This is the python code that crashes

#!/usr/bin/env python3
import os
import ROOT
import argparse

parser = argparse.ArgumentParser(description='Analyse events.')
parser.add_argument("inputfile")
parser.add_argument("-o","--outputfile",default="Output.root",help="Name of output file")
args = parser.parse_args()

READEVENTANALYSISLIBRARY=ROOT.gSystem.Getenv("READEVENTANALYSISLIBRARY");
ROOT.gSystem.Load(READEVENTANALYSISLIBRARY);

globalRecon = ROOT.TChain("ReconDir/Global")
globalRecon.AddFile(args.inputfile)

OutputFile = ROOT.TFile(args.outputfile,"RECREATE","ND280 Analysis")
hTrackMomenta = ROOT.TH1F("TrackMomenta", "Charged Track Momentum", 100, 0, 1000.0)

entries =  globalRecon.GetEntries()
for entry in range(entries):
	print(" entry = "+str(entry))
	ientry = globalRecon.LoadTree(entry)
	if ientry < 0:
		break
	nb = globalRecon.GetEntry(entry)
	if nb<=0:
		continue
	
	for	pid in globalRecon.PIDs :
		if(pid.Charge != 0) :
			print(" charge is "+str(pid.Charge))
		#	hTrackMomenta.Fill(pid.FrontMomentum)
OutputFile.Write()
OutputFile.Close()

The crash traceback suggest this as the line causing the crash:

#7 0x00007fe963a68e9a in TBranchElement::ReadLeavesClones(TBuffer&) () from /home/aleph/ajf/t2k/root/lib/libTree.so
#8 0x00007fe963a60899 in TBranch::GetEntry(long long, int) () from /home/aleph/ajf/t2k/root/lib/libTree.so
#9 0x00007fe963a7326b in TBranchElement::GetEntry(long long, int) () from /home/aleph/ajf/t2k/root/lib/libTree.so
#10 0x00007fe963ad7300 in TTree::GetEntry(long long, int) () from /home/aleph/ajf/t2k/root/lib/libTree.so

ROOT version

6.32.00

Installation method

prebuilt binary root_v6.32.00.Linux-almalinux9.4-x86_64-gcc11.4.tar.gz

Operating system

AlmaLinux 9.4

Additional context

No response

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions