HistStack in Pad a crash in rootpy, but not pyroot

Hello,

I have a problem drawing a histogram stack in a pad in rootpy, but not PyROOT. The two code snippets below should demonstrate the problem.

In PyROOT:

from ROOT import *

h = TH1F('htest','htest',10,0.,10.)
h.Fill(2.)

hs = THStack()
hs.Add(h)

c = TCanvas()
p = TPad('pad','pad',0.,0.5,1.,1.)
p.Draw()

p.cd()
hs.Draw()

This runs ok.

Now in rootpy:

import rootpy
from rootpy.plotting import *

h = Hist(10,0.,10.,name='htest')
h.Fill(2.)

hs = HistStack()
hs.Add(h)

c = Canvas()
p = Pad(0.,0.5,1.,1.)
p.Draw()

p.cd()
hs.Draw()

I get the error:

If I do not create a pad or if I draw the hist instead of the stack, then all is ok in rootpy. What am I missing?

Thank you,
Ana

Ana,

I’ve submitted https://github.com/rootpy/rootpy/issues/527 .

Cheers,
Wim

Hi Ana,

I’ll try to determine the cause and find a solution. What ROOT version do you have installed and how recent is your copy of rootpy?

For future rootpy problems it is best to post them on the github issues tracker:

github.com/rootpy/rootpy/issues?state=open

or on the Google groups list:

groups.google.com/forum/#!forum/rootpy-users

If we determine that the problem is with ROOT/PyROOT instead of rootpy, we then report it on ROOT’s JIRA issue tracker.

I am unable to reproduce that crash on my end while using ROOT 5.34.10 or the head of the 5.34 branch. But, I have seen similar crashes in the past. There could be a few issues at play.

Does it always crash and crash the same way each time you run it?

Does it still crash if you insert the line rootpy.log.info(‘hello’) after import rootpy?

Does it still crash the same way if you disable the rootpy error handler? Run your script with

NO_ROOTPY_HANDLER=1 python script.py

Does it still crash if you update to the latest ROOT and rootpy?

The NameError on the rootpy side could be from a race condition in the rootpy logger if it happens to be first initialized as ROOT is crashing…

Note that the signal handler was called at

The NameError on the rootpy side is probably just a nasty side effect of this crash as ROOT is heading out the door…

I would really like to determine what exactly is happening here. Again, I have seen similar crashes in ROOT causing issues on the rootpy side. Maybe there is something on the rootpy side that triggers the initial crash on the ROOT side, that then comes back to bite rootpy. But your code runs without any issues on my end.

Thanks!
Noel

Hi Noel,

Thanks for looking into this! My responses are below:

  • What ROOT version do you have installed and how recent is your copy of rootpy?

rootpy
Last Changed Rev: 3474
Last Changed Date: 2013-12-21 00:37:58 -0800 (Sat, 21 Dec 2013)

ROOT
Version 5.34/14 16 December 2013

  • Does it always crash and crash the same way each time you run it?

I tried again just now and got the same message.

  • Does it still crash if you insert the line rootpy.log.info(‘hello’) after import rootpy?

Yes, it prints hello and then the same crash.

  • Does it still crash the same way if you disable the rootpy error handler? Run your script with NO_ROOTPY_HANDLER=1 python script.py

If I do this, I don’t get the messages in the beginning but just:
"*** Break *** segmentation violation" + the same stack trace

  • Does it still crash if you update to the latest ROOT and rootpy?
    I think I am running the latest

I could try a different rootpy/ROOT version, if you suggest one.

Thanks,
Ana

Hi Ana,

Thanks for your answers. Good to hear you are using the latest versions. I am still unable to make the same code crash on my side.

I’m thinking more that this could be a real problem on the ROOT side. Maybe you could compile ROOT in debug mode and see the line where THashList::RecursiveRemove () is crashing?

Also can you try making the canvas and pad at the beginning instead of after the histograms?

[code]from rootpy.plotting import *

c = Canvas()
p = Pad(0.,0.5,1.,1.)
p.Draw()

h = Hist(10,0.,10.,name=‘htest’)
h.Fill(2.)

hs = HistStack()
hs.Add(h)

p.cd()
hs.Draw()[/code]

Hi Ana,

Can you try updating rootpy and running your code with:

DEBUG=1 NO_ROOTPY_KEEPALIVE=1 python test.py

This will disable the feature that keeps the stack alive as long as the pad is.

Thanks,
Noel