ROOT Version: 6.22 Platform: Linux Compiler: Not Provided
Hey all,
I’m currently running a program that has two histograms, one of which I draw a fit graph on. The first time I run it, it works fine, but if I try to load the macro again I get a segmentation violation error. When I quit root, I further get an error saying “double free or corruption (!prev)”. This only happens when I add the fit graph; without it, the code runs fine. Here’s the code in charge of graphing:
//create canvas
auto c = new TCanvas("Z Boson Data", "Z Boson Data", 1200, 600);
c->Divide(1, 2);
//graph mass histogram and fit Breit-Wigner to it
c->cd(1);
TF1 *func = new TF1("mybw",mybw,mass_bound_low, mass_bound_high, 3);
func->SetParameter(1, resonance_width); //get gamma/resonance width for parameter 1
func->SetParameter(2, mass_hist->GetMean()); //get M/Z mass for parameter 2
auto mass_fit = mass_hist->Fit("mybw", "QR");
//mass_fit->DrawClone("Same");
mass_hist->DrawClone("Same");
//graph momentum histogram
c->cd(2);
p_hist->DrawClone("Same");
I’m not double-freeing any of these graphs with a delete statement, so I don’t know why I would be getting such an error.
The code is comparable, but the error message is not. My error message tells me that there was a segmentation violation, that root crashed, and gives me a “stack trace of all threads.”
I’m using DrawClone because I’ve had problems with the graph where if I don’t use DrawClone, then the p_hist histogram simply won’t display. This is also something that wasn’t a problem before I used the fit graph.