Crash in XGetGCValues


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.24.00
Platform: CentOS 8
Compiler: gcc 8.4.1


I’m trying to write a GUI which has multiple layouts depending on the stage it is in. When I get to the second layout, any resizing of the window causes a crash:

===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0  0x00007f003f06aaab in waitpid () from /lib64/libc.so.6
#1  0x00007f003efe64af in do_system () from /lib64/libc.so.6
#2  0x00007f0045c51a03 in TUnixSystem::StackTrace() () from /opt/cern/root/root_v6.24.00/lib/libCore.so
#3  0x00007f0045c54305 in TUnixSystem::DispatchSignals(ESignals) () from /opt/cern/root/root_v6.24.00/lib/libCore.so
#4  <signal handler called>
#5  0x00007f00413a891c in XGetGCValues () from /lib64/libX11.so.6
#6  0x00007f0025f7af94 in TGX11::GetGCValues(unsigned long, GCValues_t&) () from /opt/cern/root/root_v6.24.00/lib/libGX11.so
#7  0x00007f00254a49b0 in TGX11TTF::DrawString(unsigned long, unsigned long, int, int, char const*, int) () from /opt/cern/root/root_v6.24.00/lib/libGX11TTF.so
#8  0x00007f004639ca0c in TGString::Draw(unsigned long, unsigned long, int, int) () from /opt/cern/root/root_v6.24.00/lib/libGui.so
#9  0x00007f0046282bc9 in TGButtonGroup::DrawBorder() [clone .part.12] () from /opt/cern/root/root_v6.24.00/lib/libGui.so
#10 0x00007f00462976fc in TGClient::DoRedraw() () from /opt/cern/root/root_v6.24.00/lib/libGui.so
#11 0x00007f0046298e48 in TGClient::ProcessOneEvent() () from /opt/cern/root/root_v6.24.00/lib/libGui.so
#12 0x00007f0046298eba in TGClient::HandleInput() () from /opt/cern/root/root_v6.24.00/lib/libGui.so
#13 0x00007f0045c54a28 in TUnixSystem::DispatchOneEvent(bool) () from /opt/cern/root/root_v6.24.00/lib/libCore.so
#14 0x00007f0045b6e3b1 in TSystem::Run() () from /opt/cern/root/root_v6.24.00/lib/libCore.so
#15 0x00007f0045b0647f in TApplication::Run(bool) () from /opt/cern/root/root_v6.24.00/lib/libCore.so
#16 0x00007f00433979c6 in TRint::Run(bool) () from /opt/cern/root/root_v6.24.00/lib/libRint.so
#17 0x00000000004021ea in main (argc=3, argv=0x7ffec6a86b98) at src/grsisort.cxx:81
===========================================================

Unfortunately I can’t post a minimal working example, but does anyone know what could cause a crash in the XGetGCValues function?

EDIT: I was able to reproduce this in an example:

void Test()
{
   auto mainFrame = new TGMainFrame();
   auto tab = new TGTab(mainFrame, 1200, 600);
   auto sourceTab = tab->AddTab("Tab 1");
   auto subTab = new TGTab(sourceTab, 1200, 500);
   auto channelTab = subTab->AddTab("tab 1");
   
   // top frame with two canvases amd status bar
   auto topFrame = new TGHorizontalFrame(channelTab, 1200, 450);
   auto projectionCanvas = new TRootEmbeddedCanvas("ProjectionCanvas", topFrame, 600, 400);
   auto calibrationCanvas = new TRootEmbeddedCanvas("CalibrationCanvas", topFrame, 600, 400);

   topFrame->AddFrame(projectionCanvas, new TGLayoutHints(kLHintsLeft   | kLHintsTop | kLHintsExpandY | kLHintsExpandX, 2, 2, 2, 2));
   topFrame->AddFrame(calibrationCanvas, new TGLayoutHints(kLHintsRight | kLHintsTop | kLHintsExpandY | kLHintsExpandX, 2, 2, 2, 2));

   channelTab->AddFrame(topFrame, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 2, 2));

   auto fStatusBar = new TGStatusBar(channelTab, 1200, 50);
   channelTab->AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 2, 2, 2, 2));

   // bottom frame with navigation button group, text entries, etc.
   auto bottomFrame = new TGHorizontalFrame(channelTab, 1200, 50);

   auto leftFrame = new TGVerticalFrame(bottomFrame, 600, 50);
   auto navigationGroup = new TGHButtonGroup(leftFrame, 1, 4);
   auto previousButton = new TGTextButton(navigationGroup, "Previous");
   auto calibrateButton = new TGTextButton(navigationGroup, "Calibrate");
   auto doneButton = new TGTextButton(navigationGroup, "Done");
   auto nextButton = new TGTextButton(navigationGroup, "Next");

   leftFrame->AddFrame(navigationGroup, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 2, 2));

   bottomFrame->AddFrame(leftFrame, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));

   auto rightFrame = new TGVerticalFrame(bottomFrame, 600, 50);
   auto sigmaEntry = new TGNumberEntry(rightFrame, 2., 5, 0, TGNumberFormat::EStyle::kNESRealOne, TGNumberFormat::EAttribute::kNEAPositive);
   auto thresholdEntry = new TGNumberEntry(rightFrame, 0.05, 5, 1, TGNumberFormat::EStyle::kNESRealTwo, TGNumberFormat::EAttribute::kNEAPositive, TGNumberFormat::ELimit::kNELLimitMinMax, 0., 1.);
   auto quadraticButton = new TGCheckButton(rightFrame, "Include quadratic term");

   rightFrame->AddFrame(sigmaEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));
   rightFrame->AddFrame(thresholdEntry, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));
   rightFrame->AddFrame(quadraticButton, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));

   bottomFrame->AddFrame(rightFrame, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 2, 2, 2, 2));

   channelTab->AddFrame(bottomFrame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 2, 2, 2, 2));

   sourceTab->AddFrame(subTab, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2));

   mainFrame->AddFrame(tab, new TGLayoutHints(kLHintsTop | kLHintsCenterX | kLHintsExpandX, 0, 0, 0, 0));

   // Map all subwindows of main frame
   mainFrame->MapSubwindows();

   // Initialize the layout algorithm
   mainFrame->Resize(TGDimension(1200, 600));

   // Map main frame
   mainFrame->MapWindow();
}

Since the crash seems to come from the TGButtonGroup, I tried simply removing the line where I add the button group to the left frame, but that didn’t change anything. I need to comment out the whole button group for this script not to crash.

The button group crashes the script even without any buttons added to it.

Hmm, I thought I found my mistake when I noticed that I forgot to set a title for the button group (so I assume it tried to access a string at memory location 1).

So I changed the constructor call to

auto navigationGroup = new TGHButtonGroup(leftFrame, "test");

and now it works.

I don’t know where I got the idea from that the button group takes the number of rows and columns as an argument for its constructor …

You can also simply use auto navigationGroup = new TGHButtonGroup(leftFrame);. I’ll check why it crashes when using the number of columns and rows

OK, you can either use auto navigationGroup = new TGHButtonGroup(leftFrame); or auto navigationGroup = new TGButtonGroup(leftFrame, 1, 4);

Oh, I see. I used the signature of the TGButtonGroup constructor for a TGHButtonGroup. At least now I know where I got the wrong idea from :blush:

1 Like

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