Segfault when moving text with loglog axis on multiple TGraphErrors

ROOT Version: 6.28/08
Platform: Linux Fedora 38
Compiler: g++ (GCC) 13.2.1


Hi,

When I plot 2 TGraphErrors on the same plot with loglog axis and I try to move with the mouse some text (TLatex) the code crash with

/usr/include/c++/13/bits/stl_vector.h:1125: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = double; _Alloc = std::allocator<double>; reference = double&; size_type = long unsigned int]: Assertion '__n < this->size()' failed

see for example the code below. If X axis is not in log scale or if I plot only 1 TGraphErrors, everything is working normally.

Thanks for your help
Cheers,
Olivier.

Code sample:

 {
    int N = 10;
    double xstart = 1;
    double xend = 1e3;
    //
    // defined x with log steps
    //
    double *x = new double[N];
    double dx = log(xend / xstart) / double(N - 1);
    for(int i = 0 ; i < N ; i++)
        x[i] = xstart * exp(double(i) * dx);

    //
    // define the number of graphes
    //
    int Ngr = 2;
    double *l = new double[Ngr];
    double **y = new double*[Ngr];
    for(int j = 0 ; j < Ngr ; j++)
    {
        l[j] = 0.1 / pow(10.,j);
        y[j] = new double[N];
        for(int i = 0 ; i < N ; i++)
            y[j][i] = 1 - exp(-l[j]*x[i]);
    }
    //
    // Set loglog axis on TCanvas
    //
    TCanvas *c1 = new TCanvas("c1");
    c1->DrawFrame(xstart, 1e-2, xend, 5.);
    c1->SetLogx(1);
    c1->SetLogy(1);
    
    TGraphErrors **gr = new TGraphErrors*[Ngr];
    TLatex **Legend = new TLatex*[Ngr];
    for(int j = 0 ; j < Ngr ; j++)
    {
        gr[j] = new TGraphErrors(N, x, y[j]);
        stringstream tmp;
        tmp.str("");
        tmp << "graph" << j;
        gr[j]->SetName(tmp.str().c_str());
        gr[j]->SetMarkerStyle(20);
        gr[j]->Draw("PL");
    
        Legend[j] = new TLatex(0.3 * x[N-1], 0.5 * y[j][N-1], tmp.str().c_str());
        Legend[j]->SetName(tmp.str().c_str());
        Legend[j]->Draw();
    }
    c1->Update();

}

I cannot reproduce the problem on Mac with the latest root version. Maybe that’s a Fedora issue. Do you have a more complete trace back of the crash?

Hi,
if I run gdb on the same (compiled) program I obtain:

#0  0x0000155552fcf884 in __pthread_kill_implementation () at /lib64/libc.so.6
#1  0x0000155552f7eafe in raise () at /lib64/libc.so.6
#2  0x0000155552f6787f in abort () at /lib64/libc.so.6
#3  0x00001555532df1a0 in __gnu_debug::_Safe_sequence_base::_M_get_mutex() () at /lib64/libstdc++.so.6
#4  0x0000155553eed847 in TPad::ClipPolygon(int, double*, double*, int, double*, double*, double, double, double, double) () at /usr/lib64/root/libGpad.so.6.28
#5  0x0000155553ef97aa in TPad::PaintFillArea(int, double*, double*, char const*) () at /usr/lib64/root/libGpad.so.6.28
#6  0x000015555451668e in TArrow::PaintArrow(double, double, double, double, float, char const*) ()
    at /usr/lib64/root/libGraf.so.6.28
#7  0x0000155553f04a6f in TPad::PaintModified() () at /usr/lib64/root/libGpad.so.6.28
#8  0x0000155553f0499d in TPad::PaintModified() () at /usr/lib64/root/libGpad.so.6.28
#9  0x0000155553ec6a0c in TCanvas::Update() () at /usr/lib64/root/libGpad.so.6.28
#10 0x000015555458a78f in TText::ExecuteEvent(int, int, int) () at /usr/lib64/root/libGraf.so.6.28
#11 0x0000155553ec0f66 in TCanvas::HandleInput(EEventType, int, int) () at /usr/lib64/root/libGpad.so.6.28
#12 0x000015555536e4e7 in TRootCanvas::HandleContainerMotion(Event_t*) () at /usr/lib64/root/libGui.so.6.28
#13 0x000015555527be50 in TGFrame::HandleEvent(Event_t*) () at /usr/lib64/root/libGui.so.6.28
#14 0x000015555521be30 in TGClient::HandleEvent(Event_t*) () at /usr/lib64/root/libGui.so.6.28
#15 0x000015555521c1cd in TGClient::ProcessOneEvent() () at /usr/lib64/root/libGui.so.6.28
#16 0x000015555521c21b in TGClient::HandleInput() () at /usr/lib64/root/libGui.so.6.28
#17 0x0000155554d20d70 in TUnixSystem::DispatchOneEvent(bool) () at /usr/lib64/root/libCore.so.6.28
#18 0x0000155554c2c680 in TSystem::Run() () at /usr/lib64/root/libCore.so.6.28
#19 0x0000155554bb9eaf in TApplication::Run(bool) () at /usr/lib64/root/libCore.so.6.28
#20 0x0000000000402b22 in main ()

Valgrind did not tell anything more usefull.

In $ROOTSYS/etc/system.rootrc

Try to change:

Canvas.ShowGuideLines:      on

to

Canvas.ShowGuideLines:      false

Thanks very much ; this solve my problem!
Cheers,
Olivier

1 Like

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