TLatex crashing in PyROOT after many uses

I am generating a handful of plots in a loop, and using TLatex on each iteration.
Histograms are fed to a function which draws the histograms on a canvas along with some text, many of the plots are successfully generated but after about ~30 I get the following error:

 *** Break *** segmentation violation
 Generating stack trace...
Traceback (most recent call last):
  File "./devdEdxpid.py", line 70, in <module>
    plot.draw(draw_opt='e',legend_marker='lep',fit='gaus')
  File "/home/ddavis/Dropbox/pidplot/pidplot/pidplot.py", line 283, in draw
    hist1print.DrawLatex(.76,.75,'Fit #it{#mu} = '   +self.fit_means[0][0] +'#pm '+self.fit_means[0][1])
SystemError: TLatex* TLatex::DrawLatex(double x, double y, const char* text) =>
    problem in C++; program state has been reset

I get this whether I create the TLatex object inside the function which gets called many times, or if I make the TLatex object global and just call TLatex::DrawLatex each time the function is called in the loop. I’m guessing it’s some kind of C++ memory issue?

Hi,

which ROOT version are you using and what script are you running?

Cheers,
Danilo

I’ve run this code on OS X (10.11) with ROOT version 6.06.06 and also on Arch Linux with a build from the ROOT master branch (~1 week old).

In the code below, pidplot.py has a class called multiHist which I use in a loop in devdEdxpid.py, multiHist.draw() is the function where TLatex::DrawLatex is called.
pidplot.py (13.9 KB)
devdEdxpid.py (5.05 KB)

Hi,

the file pidstyling seems to be missing. Can you reduce the problem to a smaller strandalone script?

D

Hello,
I was able to solve the problem using
ROOT.SetOwnership(canvas,False) to kill the canvas when finished with it
Thanks!