ROOT6 - Canvas won't display

In my view, it really has to do with the fit and storing the fit results on the canvas itself.

Something simple as

  TFile outfile(outname, "recreate");
  rate.Fit("pol1", "EX0");
  rate.Write("rate");

with “rate” a valid TGraphErrors, generates a .root file where drawing “rate” leads to a segmentation violation.

Whereas using the “N” option as in the following

  TFile outfile(outname, "recreate");
  rate.Fit("pol1", "NEX0");
  rate.Write("rate");

generates a valid .root file from which “rate” can be drawn (though the fit is of course missing).

Best regards,
Valérian

I am debugging.

If I run the macro with 6.02 and generate a root file with it I can then draw the canvas with 6.02 but I get the crash with the master… I do not have any clue right now… give me some time…

Thank you very much for your time :slight_smile:, everything was running fine a few weeks of commits ago indeed!

I see that all is fine with 6.02.

To keep track. Here is where I am.

The the following with 6.02:

void unnamed()
{
   TCanvas *c1 = new TCanvas("c1", "c1",0,0,400,400);

   Double_t fx1009[6] = { 0.2715554, 0.295, 0.3183333, 0.3416667, 0.365, 0.3883333};
   Double_t fy1009[6] = { 6.105087, 5.692255, 5.619629, 5.3808, 5.441179, 5.381391};
   Double_t fex1009[6] = { 0.01166667, 0.01166667, 0.01166667, 0.01166667, 0.01166667, 0.01166667};
   Double_t fey1009[6] = { 0.3546846, 0.1337318, 0.09532397, 0.07191573, 0.09626983, 0.1180724};

   TGraphErrors *gre = new TGraphErrors(6,fx1009,fy1009,fex1009,fey1009);

   TF1 *PrevFitTMP1010 = new TF1("PrevFitTMP","pol1",0.246,0.414);
   gre->GetListOfFunctions()->Add(PrevFitTMP1010);

   gre->Draw("AP");

   c1->SaveAs("unnamed.root");
}

It generated “unnamed.root”

with the ROOT master do:

$ root unnamed.root 
   ----------------------------------------------------------------
  | Welcome to ROOT 6.05/01                    http://root.cern.ch |
  |                                   (c) 1995-2014, The ROOT Team |
  | Built for macosx64                                             |
  | From heads/master@v6-05-01-300-g0aefc8d, Jul 07 2015, 14:32:14 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'     |
   ----------------------------------------------------------------

root [0] 
Attaching file unnamed.root as _file0...
(class TFile *) 0x7f8239e544c0
root [1] c1->Draw()

You get:

Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) extern "C" void __cf_0(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      new (ret) (double) (TFormula____id9545039756528417102(*(double**)args[0], *(double**)args[1]));
      return;
   }
   else {
      TFormula____id9545039756528417102(*(double**)args[0], *(double**)args[1]);
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====

 *** Break *** segmentation violation

Even simpler:

void unnamed()
{
   TCanvas *c1 = new TCanvas("c1", "c1",0,0,400,400);

   Double_t fx1[3]  = { 0.2, 0.3, 0.4};
   Double_t fy1[3]  = { 6.1, 5.6, 3.6};
   Double_t fex1[3] = { 0.1, 0.2, 0.3};
   Double_t fey1[3] = { 0.3, 0.1, 0.5};

   TGraphErrors *gre = new TGraphErrors(3,fx1,fy1,fex1,fey1);

   TF1 *pol1 = new TF1("pol1","pol1",0.246,0.414);
   gre->GetListOfFunctions()->Add(pol1); // The faulty line

   gre->Draw("AP");

   c1->SaveAs("unnamed.root");
}

Ok, I am now at a three lines macros level. It seems something connected with TF1. The macro is:

{
   TF1 *pol1 = new TF1("pol1","pol1",0.,10.);
   pol1->Draw();
   c1->SaveAs("unnamed.root");
}

1st run in 6.02:

$ root unnamed.C
   -------------------------------------------------------------------------
  | Welcome to ROOT 6.02/13                             http://root.cern.ch |
  |                                            (c) 1995-2014, The ROOT Team |
  | Built for macosx64                                                      |
  | From heads/v6-02-00-patches@v6-02-12-15-gaed9ff3, Jul 07 2015, 08:52:54 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'              |
   -------------------------------------------------------------------------

root [0] 
Processing unnamed.C...
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
Info in <TCanvas::SaveAs>: ROOT file unnamed.root has been created
root [1] 

Then run ROOT master with:

$ root unnamed.root 
   ----------------------------------------------------------------
  | Welcome to ROOT 6.05/01                    http://root.cern.ch |
  |                                   (c) 1995-2014, The ROOT Team |
  | Built for macosx64                                             |
  | From heads/master@v6-05-01-302-ge19b18b, Jul 07 2015, 16:13:46 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'     |
   ----------------------------------------------------------------

root [0] 
Attaching file unnamed.root as _file0...
(class TFile *) 0x7fe1c168a620
root [1] 

and you get:

root [1] c1->Draw()
Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push

Our TF1 expert is on holidays right now. I will tell him to look at it when he will be back.

OK, thank you!

Hello,

Would there be anything new coming up about the issue?

Best regards,
Valérian

Hi,
We have identified the cause of the problem. We will fix later on, but for the time being, retrieve the objects from the file using the function TFile::Get and it should work.
Don’t use the automatic feature to retrieve objects (TF1 or objects containing TF1 like TCanvas) by its name, which will not work anyway in a macro.

I have opened a JIRA ticket, see
sft.its.cern.ch/jira/browse/ROOT-7512

Best Regards

Lorenzo

Hi Lorenzo,

Thank you for the workaround and for opening the ticket !

Best regards,
Valérian