Core dump in StelQGLRenderer

Bug #1044654 reported by Sibi Antony
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stellarium
Fix Released
Medium
Ferdinand Majerech

Bug Description

Noticed an arithmetic exception and a core dump with the recent changes. A division by zero in StelQGLRenderer.cpp.

Program terminated with signal 8, Arithmetic exception.
#0 0x00000000005ddd03 in StelQGLRenderer::drawTextGravityHelper (this=0x187ac60, params=..., painter=..., baseX=1018, baseY=525, projector=...)
    at /home/sibi/TUM/IDP/stellarium/stellarium_11.2/stellarium/src/core/renderer/StelQGLRenderer.cpp:271
271 const float charWidth = painter.fontMetrics().width(string) / charCount;

(gdb) bt
#0 0x00000000005ddd03 in StelQGLRenderer::drawTextGravityHelper (this=0x187ac60, params=..., painter=..., baseX=1018, baseY=525, projector=...)
    at /home/sibi/TUM/IDP/stellarium/stellarium_11.2/stellarium/src/core/renderer/StelQGLRenderer.cpp:271
#1 0x00000000005de5d8 in StelQGLRenderer::drawText (this=0x187ac60, params=...)
    at /home/sibi/TUM/IDP/stellarium/stellarium_11.2/stellarium/src/core/renderer/StelQGLRenderer.cpp:349
#2 0x000000000081064f in TextUserInterface::draw (this=0x3464860, core=0x1d0d990, renderer=0x187ac60)
    at /home/sibi/TUM/IDP/stellarium/stellarium_11.2/stellarium/plugins/TextUserInterface/src/TextUserInterface.cpp:610
#3 0x000000000058ac93 in StelModule::drawPartial (this=0x3464860, core=0x1d0d990, renderer=0x187ac60)

Would be good to check the string size before going ahead. Something like this.

  const int charCount = string.length();
+
+ if (!charCount)
+ {
+ return;
+ }
+
  const float charWidth = painter.fontMetrics().width(string) / charCount;

Or better yet, check the string params in drawText().
The TUI plugin forwarded an empty string for selected object (no object selected and empty). So perhaps some optimization in there too.

- if (selectedObj.isEmpty()) {
- objInfo = "";
- } else {
+ if (!selectedObj.isEmpty()) {
                        objInfo = selectedObj[0]->getInfoString(core, tuiInfo);
                        objInfo.replace("\n"," ");
                        objInfo.replace("Distance:"," ");
                        objInfo.replace("Light Years","ly");

                        if (fovMaskDisk) {
                                text_x = xVc + fovOffsetX - pixOffset;
                                text_y = yVc + fovOffsetY - pixOffset;
                        }

                        renderer->setFont(font);
                        renderer->setGlobalColor(0.3f, 1.0f, 0.3f);
                        TextParams params = TextParams(text_x, text_y, objInfo)
                                            .projector(core->getProjection(StelCore::FrameJ2000));
                        if(tuiGravityUi){params.useGravity();}
                        renderer->drawText(params);
                }

Related branches

summary: - Seg fault in StelQGLRenderer
+ Core dump in StelQGLRenderer
Changed in stellarium:
assignee: nobody → Ferdinand Majerech (kiithsacmp)
status: New → In Progress
importance: Undecided → Medium
milestone: none → 0.12.0
Changed in stellarium:
status: In Progress → Fix Committed
Changed in stellarium:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.