Problem to read `TF1`/`TFormula` stored with previous ROOT versions
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.
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();
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
Is there a fix for this @lmoneta ?
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
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