root icon indicating copy to clipboard operation
root copied to clipboard

Problem to read `TF1`/`TFormula` stored with previous ROOT versions

Open linev opened this issue 3 years ago • 5 comments

Approx 10 years ago I create file with canvas from TLegend docu.

Now it is impossible to correctly read produced canvas and draw TF1 object in it:

root https://root.cern/js/files/legends.root -e "legends->Draw()"

Command produce a lot of error output like:

Error in <TClingCallFunc::make_wrapper>: Failed to compile
  ==== SOURCE BEGIN ====
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-security"
__attribute__((used)) __attribute__((annotate("__cling__ptrcheck(off)")))
extern "C" void __cf_1(void* obj, int nargs, void** args, void* ret)
{
   if (ret) {
      new (ret) (double) (((double (&)(double *))TFormula____id1925463321337447592)(*(double**)args[0]));
      return;
   }
   else {
      (void)(((double (&)(double *))TFormula____id1925463321337447592)(*(double**)args[0]));
      return;
   }
}
#pragma clang diagnostic pop
  ==== SOURCE END ====
Error in <prepareFuncPtr>: Compiled function pointer is null
Error in <TFormula::InputFormulaIntoCling>: Error compiling formula expression in Cling
Error in <TFormula::ProcessFormula>: Formula "1000*TMath::Abs(sin(x)/x)" is invalid !
Error in <TFormula::Eval>: Formula is invalid and not ready to execute 
TMath::Abs is unknown.
Error in <TFormula::Eval>: Formula is invalid and not ready to execute 
TMath::Abs is unknown.
Error in <TFormula::Eval>: Formula is invalid and not ready to execute 
TMath::Abs is unknown.
Error in <TFormula::Eval>: Formula is invalid and not ready to execute 
TMath::Abs is unknown.
Error in <TFormula::Eval>: Formula is invalid and not ready to execute 
TMath::Abs is unknown.

Producing segfault when trying to quit ROOT session.

linev avatar Mar 28 '23 08:03 linev

The problem is in automatic reading the objects, probably for some missing library (as in this case the TMath::Abs definition). I think we had similar issues with TFormula/TF1 before. There is the simple workaround:

auto legends = file->Get("legends")
legends->Draw();

lmoneta avatar Apr 03 '23 15:04 lmoneta

The problem is that the flag fLazyInitialization is not set to true when reading an old Formula (v5) from the file. I will provide a fix for this

lmoneta avatar Apr 03 '23 16:04 lmoneta

Is there a fix for this @lmoneta ?

dpiparo avatar Jun 02 '24 05:06 dpiparo

Hi @guitargeek , I noticed this issue is currently assigned to you. I was interested in working on it after reading through the discussion and investigating the reported root cause. Are you still working on it? If not, I’d be happy to take it on

ankit-cybertron avatar Jun 27 '26 10:06 ankit-cybertron

I check master branch - and problem gone now. Would be nice to identify fix when it was done. But I mark next ROOT version as resolving the problem

linev avatar Aug 05 '26 06:08 linev