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 "./", line 70, in <module>
  File "/home/ddavis/Dropbox/pidplot/pidplot/", 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?


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


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, has a class called multiHist which I use in a loop in, multiHist.draw() is the function where TLatex::DrawLatex is called. (13.9 KB) (5.05 KB)


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


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