TRatioPlot seg fault in PyROOT

If I try to run the ratioplot1.C tutorial ($ROOTSYS/tutorials/hist/ratioplot1.C) equivalent code in PyROOT (see below) creating a TRatioPlot causes a seg fault. Does this occur for other people on similar architectures, and is there currently a way to create ratio plots in PyROOT other than the way shown in the ratioplot.py tutorial ($ROOTSYS/tutorials/pyroot/ratioplot.py)?

The plot will be created, but the segfault happens when ROOT.TRatioPlot(h1, h2) is called.

System Information:

$ uname -a
Linux mcf-ThinkPad-Edge-E540 4.4.0-51-generic #72-Ubuntu SMP Thu Nov 24 18:29:54 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ root-config --version
6.09/01
python --version
Python 3.5.2 :: Anaconda custom (64-bit)

ratioplot1.C equivalent code:

import ROOT

if __name__ == '__main__':
    c1 = ROOT.TCanvas("c1", "A ratio example")
    h1 = ROOT.TH1D("h1", "h1", 50, 0, 10)
    h2 = ROOT.TH1D("h2", "h2", 50, 0, 10)
    f1 = ROOT.TF1("f1", "exp(- x/[0] )")
    f1.SetParameter(0, 3)
    h1.FillRandom("f1", 1900)
    h2.FillRandom("f1", 2000)
    h1.Sumw2()
    h2.Scale(1.9 / 2.)
    h1.GetXaxis().SetTitle("x")
    h1.GetYaxis().SetTitle("y")
    rp = ROOT.TRatioPlot(h1, h2)
    c1.SetTicks(0, 1)
    rp.Draw()
    c1.Update()
    c1.SaveAs("ratio.pdf")
    c1.Destructor()

seg_fault.out.txt (5.43 KB)

I see the crash to with:

from ROOT import *

c1 = TCanvas("c1", "A ratio example")
h1 = TH1D("h1", "h1", 50, 0, 10)
h2 = TH1D("h2", "h2", 50, 0, 10)
f1 = TF1("f1", "exp(- x/[0] )")
f1.SetParameter(0, 3)
h1.FillRandom("f1", 1900)
h2.FillRandom("f1", 2000)
h1.Sumw2()
h2.Scale(1.9 / 2.)
h1.GetXaxis().SetTitle("x")
h1.GetYaxis().SetTitle("y")
rp = TRatioPlot(h1, h2)
c1.SetTicks(0, 1)
rp.Draw()
c1.Update()
c1.SaveAs("ratio.pdf")
$ python ratioplot1.py 
Info in <TCanvas::Print>: pdf file ratio.pdf has been created

 *** Break *** segmentation violation
[<unknown binary>]
[<unknown binary>]
[/Users/couet/git/roottrunk-bin/lib/libGpad.so] TRatioPlot::~TRatioPlot() /Users/couet/git/roottrunk/graf2d/gpad/src/TRatioPlot.cxx:162
[/Users/couet/git/roottrunk-bin/lib/libPyROOT.so] PyROOT::op_dealloc_nofree(PyROOT::ObjectProxy*) /Users/couet/git/roottrunk/bindings/pyroot/src/ObjectProxy.cxx:65
[/Users/couet/git/roottrunk-bin/lib/libPyROOT.so] PyROOT::(anonymous namespace)::op_dealloc(PyROOT::ObjectProxy*) /Users/couet/git/roottrunk/bindings/pyroot/src/ObjectProxy.cxx:213

it crashes in the TRatioPlot destructor. No idea why yet. The pdf file is created properly though…

I am running on Mac with ROOT master.

Fixed in the master. Thanks to have seen it.

Great! So the fix has been committed and I should just be able to pull down the latest commit (at root.cern.ch/git/root.git) and rebuild, correct?

Yes

Hi, @couet. This was fixed in ROOT v6.09 (thanks!), however it still exists in ROOT v6.08.

I am noticing the same behavior we say back in December on lxplus with this configuration:

$ uname -a
Linux lxplus022.cern.ch 2.6.32-642.15.1.el6.x86_64 #1 SMP Fri Feb 24 16:56:37 CET 2017 x86_64 x86_64 x86_64 GNU/Linux
$ root-config --version
6.08/07
$ python --version
Python 2.7.13

Can the fix that you put into ROOT v6.09 also be applied to the patches for ROOT v6.08? I would like to use TRatioPlot in the ROOT v6.08 available on lxplus through CVMFS as described in this issue here.

Yes it was fixed in master only (6.09). We usually back port the blocking problems or those which can’t be turned around. If it is the case I will port it back.

Hi @couet, so for this problem are you able to back port it?

The working version from the master has been imported in 6.08

Okay, so I assume that means it is now in the master branch for 6.08. Sorry to ask a stupid question, but is there a way for me to use this on CVMFS besides trying to find it in the nightlies? That is, is there someway for me to source it in a similar fashion to an LCG release,

$ . /cvmfs/sft.cern.ch/lcg/releases/LCG_88/ROOT/6.08.06/x86_64-slc6-gcc62-opt/ROOT-env.sh

?

Until we release a new patch release of v6.08 it’s only in the nightly builds. We will likely release the next patch release during the second half of April.

Axel

1 Like