Segfault when gDirectory.Get()

Hello,

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

[code]#!/usr/bin/python

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:

[quote]6.05/01

*** Break *** segmentation violation
Generating stack trace…
0x00007f1c65ae7be3 in PyObject_Call + 0x43 from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65b79a8a in PyEval_EvalFrameEx + 0x399a from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65b7c9b0 in PyEval_EvalCodeEx + 0x830 from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65b7caa9 in PyEval_EvalCode + 0x19 from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65b956ff in from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65b96872 in PyRun_FileExFlags + 0x72 from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65b97977 in PyRun_SimpleFileExFlags + 0xd7 from /usr/lib64/libpython2.7.so.1.0
0x00007f1c65ba89ca in Py_Main + 0xc3a from /usr/lib64/libpython2.7.so.1.0
0x00007f1c654ecfd0 in __libc_start_main + 0xf0 from /lib64/libc.so.6
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:

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

[code]{
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;
}[/code]
I have also tried in the latest 6.04, where I get no segfault, but where the problem reported [url=https://root-forum.cern.ch/t/wrong-event-count-in-root-6-02-10/19335/1 is still present.

Yours,
Sébastien

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

Hi, sorry,

You can find it at /afs/cern.ch/user/s/swertz/public/temp_testbug/bug_hist.root

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

Hi,

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.

Thanks,
Wim

Hi,

Yes, I followed the procedure here: root.cern.ch/drupal/content/roo … 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:

Thanks!
Sébastien

Hi,

“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.

Cheers,
Wim

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