Segfault when gDirectory.Get()


I’ve just updated to the latest 6.02 pach release (6.02/12). I’m trying to execute the following code:


import ROOT

print ROOT.gROOT.GetVersion()

file = ROOT.TFile(“bug_hist.root”, “READ”)
tree = file.Get(“Event”)
tree.Draw(“Entries$>>tempHist”, “”, “goff”)
tempHist = ROOT.gDirectory.Get(“tempHist”)
entries = tempHist.Integral()

print “Integral=”, entries
print “Entries=”, tempHist.GetEntries()[/code]
But I’m getting a segfault. Here’s the output:


*** Break *** segmentation violation
Generating stack trace…
0x00007f1c65ae7be3 in PyObject_Call + 0x43 from /usr/lib64/
0x00007f1c65b79a8a in PyEval_EvalFrameEx + 0x399a from /usr/lib64/
0x00007f1c65b7c9b0 in PyEval_EvalCodeEx + 0x830 from /usr/lib64/
0x00007f1c65b7caa9 in PyEval_EvalCode + 0x19 from /usr/lib64/
0x00007f1c65b956ff in from /usr/lib64/
0x00007f1c65b96872 in PyRun_FileExFlags + 0x72 from /usr/lib64/
0x00007f1c65b97977 in PyRun_SimpleFileExFlags + 0xd7 from /usr/lib64/
0x00007f1c65ba89ca in Py_Main + 0xc3a from /usr/lib64/
0x00007f1c654ecfd0 in __libc_start_main + 0xf0 from /lib64/
0x000000000040073e in from python[/quote]
Testing line-by-line, it appears that the problem is due to “gDirectory.Get()”. And btw, why is the version 6.05/01? I followed the instructions here.

The code works fine under 5.34/20, yielding the following output:

Integral= 15818.0
Entries= 15818.0[/quote]
There is also no problem when executing the exact corresponding code in C++:

TFile* myFile = new TFile(“bug_hist.root”,“READ”);
TTree* myTree = (TTree*) myFile->Get(“Event”);
myTree->Draw(“Entries$>>tempHist”, “”, “goff”);
TH1F* tempHist = (TH1F*) gDirectory->Get(“tempHist”);
double myEntries = tempHist->Integral();

cout << "Integral = " << myEntries << endl;
cout << "nEntries = " << tempHist->GetEntries() << endl;

delete tempHist;
tempHist = nullptr;
delete myFile;
myFile = nullptr;
I have also tried in the latest 6.04, where I get no segfault, but where the problem reported [url= is still present.


I think we will need bug_hist.root to debug your problem.

Hi, sorry,

You can find it at /afs/

As such, it just contains a plain ROOT TTree… I have the same issue with other files than the ones I’ve shared.


that I don’t know; did you do the “git checkout -b v6-02-00-patches”? Either way, 6.05/01 is the only broken version. :slight_smile: Now fixed.



Yes, I followed the procedure here: … ease-notes
But maybe, what I wanted (ie the latest 6.02 version) was not v6-02-00-patches, but actually v6-02-12?

Now that I think of it: I’m not a Git expert, but only doing checkout -b without doing anything else afterwards would only create a local branch, and not actually pull the branch from the official repo, wouldn’t it? If so I don’t understand the procedure oulined there…

Sorry, what do you mean? :slight_smile:



“git checkout v6-02-12” should do the trick. No git expert here either; vastly prefer mercurial.

That if you wish to continue working with master, you can do a ‘git pull’ followed by ‘make’ and your example will then run fine with ‘6.05/01’. Of course, going to what you want, v6-02-12, there should be no problem at all.


Thanks! Using 6-02-12 worked :slight_smile: