Home | News | Documentation | Download

TCanvas::SaveAs crashes

ROOT Version: 6.18 for centos
Platform: Not Provided
Compiler: g++

Dear ROOT community,

I tried to build several graphs with use of std::function, as it is presented in the script temp.cpp (2.7 KB)
And strange things happen.

I marked some functions with numbers {1…4} in comment section. I am bulding a TGraph by filling x and y array. x is filled uniformally while y is filled with value equal to fraction of two integrals which integrands are those functions {1…4}. And here what happens:
Taking a fraction of 1 & 3 produces correct output:

Taking a fraction of 2 & 4 produces axis…:
Taking a fraction of 2 & 3 works too
Taking a fraction of 1 & 4 produces segfault

So you see the problem. What is interesting here is that each x,y array is actually filled and it is actually done fairly good. So when segfault happened, I checked everything and as it turned out, it was a TCanvas::SaveAs who produced the segfault. It seems that any other error such as not building a fraction of 2 & 4 is the same issue.

The stack trace is as follows:

>  #5  0x00007fd2e4ec9841 in FT_Done_Glyph () from /lib64/libfreetype.so.6
> #6  0x00007fd2e90cec29 in TTF::LayoutGlyphs() () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #7  0x00007fd2e90cf852 in TTF::GetTextAdvance(unsigned int&, char*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #8  0x00007fd2e90d2022 in TText::GetTextAdvance(unsigned int&, char const*, bool) const () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #9  0x00007fd2e7c5d0e8 in TPDF::Text(double, double, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libPostscript.so.6.18
> #10 0x00007fd2e909ed71 in TLatex::Analyse(double, double, TLatex::TextSpec_t, char const*, int) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #11 0x00007fd2e90a3646 in TLatex::PaintLatex1(double, double, double, double, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #12 0x00007fd2e90a418b in TLatex::PaintLatex(double, double, double, double, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #13 0x00007fd2e908e1ee in TGaxis::PaintAxis(double, double, double, double, double&, double&, int&, char const*, double, bool) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGraf.so.6.18
> #14 0x00007fd2d7cfc6f5 in THistPainter::PaintAxis(bool) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libHistPainter.so.6.18.00
> #15 0x00007fd2d7cdda96 in THistPainter::Paint(char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libHistPainter.so.6.18.00
> #16 0x00007fd2d7cd04af in TGraphPainter::PaintGraph(TGraph*, int, double const*, double const*, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libHistPainter.so.6.18.00
> #17 0x00007fd2d7ccc6b7 in TGraphPainter::PaintGraphSimple(TGraph*, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libHistPainter.so.6.18.00
> #18 0x00007fd2d7cdba7c in TGraphPainter::PaintHelper(TGraph*, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libHistPainter.so.6.18.00
> #19 0x00007fd2e8b0846c in TPad::Paint(char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGpad.so.6.18
> #20 0x00007fd2e8b0846c in TPad::Paint(char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGpad.so.6.18
> #21 0x00007fd2e8b0664f in TPad::Print(char const*, char const*) () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGpad.so.6.18
> #22 0x00007fd2e8b07632 in TPad::SaveAs(char const*, char const*) const () from /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.18.00/x86_64-centos7-gcc48-opt/lib/libGpad.so.6.18
> #23 0x0000000000403b62 in main ()

Thanks in advance.

It seems that I fixed every issue just with excluding possibility of x be zero, because at that point y was -nan. Is there any built-in way to exclude possibility of such situation in future?

Hi @Silence2107,
Thank you for reporting your issue and including a solution. Probably your best bet is to filter out the null values inside the std::function itself. Maybe @couet could have some more input for you

We cannot test NaN at the graphics level: that will too consuming in time and penalise the code not generating NaN.

1 Like

Thank you for clarification.
Anyway, maybe it is not bad idea to include possibility of providing filtering function pointer? Just another overload of SaveAs, which will be used while testing code. This does not crack other projects. Or it is too much to oveload?

Your issue is probably not with with TCanvas but rather with the input data you are giving to the TGraph constructor. You should either check them in the function itself (or in the for loop) or you could give a try at the RDataFrame api that provides a Filter method.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.