Stop Calling It “Stable” and “Unstable!”


We, as an industry and a community, really need to part ways with this idea that software is stable just because it’s a release version and development versions are unstable. I would estimate at least 50% of the time, development versions of the software I use are more reliable than their so-called stable release counterparts. The same goes for software repositories in Linux distributions. Rarely are the stable channels actually, in practice, more reliable than the unstable channels. Do I think this simply because I’ve been biased by rolling-release distros? Nope. Let me prove it by using Gentoo as an example.

Qt Creator is one of my favorite and most used tools, so last night when I saw messages about its current state of brokenness while browsing #gentoo out of the corner of my eye, my spidey senses tingled.

<daedreth> alright friends, despite my best effort, opening a project in qt-creator still ends up in a segfault, how do I go about troubleshooting this?
<stqn> daedreth: my first thought is: do you have the correct CPU_FLAGS_X86 in make.conf, and the correct -march in CFLAGS
<daedreth> stqn: I use cpuid2cpuflags so they gotta be correct
<stqn> ok
<daedreth> my CFLAGS have no -march, only -o2 and -pipe
<stqn> daedreth: I’m not very familiar with segfault messages, does it contain any hint of what is happening?
<daedreth> stqn: absolutely nothing
<stqn> you can try gdb then
<daedreth> stqn: I wished I knew how to debug programs as complex as this eh
<stqn> daedreth: well just "gdb qtcreator" then "run", open the project, and gdb should tell you what’s happening, then you can type "bt" to get an idea of where the program crashed… it might give a hint
<daedreth> stqn: look at this http://imgur.com/a/4QpP1
<daedreth> thats a segfault alright
<stqn> daedreth: yeah it’s crashing in Qt5 but we don’t know why.
<daedreth> stqn: the output of bt is :http://imgur.com/a/ABZix
<daedreth> it's also crashing when trying to open "Options"
<stqn> daedreth: well I don’t know… try to reboot, make sure your whole system is up to date, check the bugtracker… :]
<daedreth> stqn: i rebooted, reinstalled gentoo, updated it, oh boi
<stqn> daedreth: stable versions of qt5 and qtcreator?
<daedreth> stqn: I emerged it normally, so... I guess
<elec_A> stqn: Thank you, just a question, does these bugs also exist in other distributions too?
<wraeth> daedreth: bug 594748 ?
<willikins> wraeth: https://bugs.gentoo.org/594748 "dev-qt/qt-creator-3.6.1: crashes when opening options"; Gentoo Linux, Current packages; UNCO; t.schmittlauch+gentoo:pesa
<stqn> elec_A: I don’t know. I don’t even know what it is.
<daedreth> wraeth: this is... precisely what I am experiencing
<wraeth> :)
<elec_A> stqn: oh Ok, anyways. Thanks for sharing the link :)
<daedreth> wraeth: so... halt my c++ projects, and wait for a fix?
<wraeth> daedreth: well, you could continue trying to debug, but the point was that you're evidently not the only one experiencing it
<daedreth> yep, got that, I spent almost 2 days trying to get rid of that bug, I give up, will just wait for a fix

I couldn’t help myself. I had to test my metal on this one (yes, that was a pun, sorry). But was it really doing that or was this person’s machine simply misconfigured (something painfully easy to do in Gentoo)? I mean, we’re talking the stable version of the package, 3.6.1. Certainly there’s no way it would be cr…

QtCreator sefaulting on options menu item.

…oh, oh my. So, what does a gdb backtrace say afterall?

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff73f5408 in QLabel::setText(QString const&) () from /usr/lib64/libQt5Widgets.so.5
(gdb) backtrace
#0  0x00007ffff73f5408 in QLabel::setText(QString const&) () from /usr/lib64/libQt5Widgets.so.5
#1  0x00007fffee028ade in Core::Internal::VariableChooserPrivate::updateDescription(QModelIndex const&) () from /usr/lib64/qtcreator/plugins/libCore.so

It actually prints out 47 frames, but this is enough to get the gist of what’s going on. The problem is in the Qt libraries. This has the stink of upstream bug. QLabel’s setText() function is trying to act on a most likely null reference that it’s receiving from VariableChooserPrivate::updateDescription(). And where is that function?

Binge user herb on 5 in /tmp
$ cp /usr/portage/distfiles/qt-creator-opensource-src-3.6.1.tar.gz .

Binge user herb on 5 in /tmp
$ tar -zxf qt-creator-opensource-src-3.6.1.tar.gz

Binge user herb on 5 in /tmp
$ cd qt-creator-opensource-src-3.6.1

Binge user herb on 5 in /tmp/qt-creator-opensource-src-3.6.1
$ grep -R "VariableChooserPrivate::updateDescription" ./*
./src/plugins/coreplugin/variablechooser.cpp:void VariableChooserPrivate::updateDescription(const QModelIndex &index)

Easy find. Leads me to wonder what’s different between the 3.6.1 and 4.1.0 versions of variablechooser.cpp.

Binge user herb on 5 in /tmp
$ ebuild /usr/portage/dev-qt/qt-creator/qt-creator-4.1.0.ebuild fetch
>>> Downloading 'http://distfiles.gentoo.org/distfiles/qt-creator-opensource-src-4.1.0.tar.xz'
--2016-11-23 03:55:43--  http://distfiles.gentoo.org/distfiles/qt-creator-opensource-src-4.1.0.tar.xz
Resolving distfiles.gentoo.org... 64.50.233.100, 216.165.129.135, 140.211.166.134, ...
Connecting to distfiles.gentoo.org|64.50.233.100|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16291164 (16M) [application/x-xz]
Saving to: '/usr/portage/distfiles/qt-creator-opensource-src-4.1.0.tar.xz'

/usr/portage/distfiles/qt 100%[====================================>]  15.54M  7.46MB/s    in 2.1s    

2016-11-23 03:55:45 (7.46 MB/s) - '/usr/portage/distfiles/qt-creator-opensource-src-4.1.0.tar.xz' saved [16291164/16291164]

 * qt-creator-opensource-src-4.1.0.tar.xz SHA256 SHA512 WHIRLPOOL size 😉 ...                  [ ok ]

Binge user herb on 5 in /tmp
$ tar -Jxf /usr/portage/distfiles/qt-creator-opensource-src-4.1.0.tar.xz

Binge user herb on 5 in /tmp
$ diff qt-creator-opensource-src-3.6.1/src/plugins/coreplugin/variablechooser.cpp qt-creator-opensource-src-4.1.0/src/plugins/coreplugin/variablechooser.cpp
--- qt-creator-opensource-src-3.6.1/src/plugins/coreplugin/variablechooser.cpp  2016-03-08 06:30:19.000000000 -0500
+++ qt-creator-opensource-src-4.1.0/src/plugins/coreplugin/variablechooser.cpp  2016-08-23 08:36:42.000000000 -0400
@@ -1,7 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
 **
 ** This file is part of Qt Creator.
 **
@@ -9,28 +9,25 @@
 ** Licensees holding valid commercial Qt licenses may use this file in
 ** accordance with the commercial license agreement provided with the
 ** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company.  For licensing terms and
-** conditions see http://www.qt.io/terms-conditions.  For further information
-** use the contact form at http://www.qt.io/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
 **
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file.  Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, The Qt Company gives you certain additional
-** rights.  These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
 **
 ****************************************************************************/
 
 #include "variablechooser.h"
 #include "coreconstants.h"
 
+#include <coreplugin/coreicons.h>
+
 #include <utils/fancylineedit.h> // IconButton
 #include <utils/headerviewstretcher.h> // IconButton
 #include <utils/macroexpander.h>
@@ -92,7 +89,7 @@
     void createIconButton()
     {
         m_iconButton = new IconButton;
-        m_iconButton->setPixmap(QPixmap(QLatin1String(":/core/images/replace.png")));
+        m_iconButton->setPixmap(Core::Icons::REPLACE.pixmap());
         m_iconButton->setToolTip(VariableChooser::tr("Insert Variable"));
         m_iconButton->hide();
         connect(m_iconButton.data(), static_cast<void(QAbstractButton::*)(bool)>(&QAbstractButton::clicked),
@@ -245,14 +242,17 @@
     : q(parent),
       m_lineEdit(0),
       m_textEdit(0),
-      m_plainTextEdit(0)
+      m_plainTextEdit(0),
+      m_iconButton(0),
+      m_variableTree(0),
+      m_variableDescription(0)
 {
     m_defaultDescription = VariableChooser::tr("Select a variable to insert.");
 
     m_variableTree = new VariableTreeView(q, this);
-    m_variableTree->setModel(&m_model);
-
     m_variableDescription = new QLabel(q);
+
+    m_variableTree->setModel(&m_model);
     m_variableDescription->setText(m_defaultDescription);
     m_variableDescription->setMinimumSize(QSize(0, 60));
     m_variableDescription->setAlignment(Qt::AlignLeft|Qt::AlignTop);
@@ -408,7 +408,8 @@
  */
 void VariableChooserPrivate::updateDescription(const QModelIndex &index)
 {
-    m_variableDescription->setText(m_model.data(index, Qt::ToolTipRole).toString());
+    if (m_variableDescription)
+        m_variableDescription->setText(m_model.data(index, Qt::ToolTipRole).toString());
 }
 
 /*!
@@ -555,7 +556,7 @@
 {
     if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
         ke->accept();
-        QTimer::singleShot(0, widget, SLOT(close()));
+        QTimer::singleShot(0, widget, &QWidget::close);
         return true;
     }
     return false;

There as been some repositioning of m_variableTree->setModel(), and a guard has been added around m_variableDescription. If I make those changes via a user patch and re-emerge QtCreator…

QtCreator No SEGFAULT

Boom!

Turns out this is a bug, #594748. I have a dozen questions about this:

  • How on earth did this ever get stabilized when the most commonly used menu option does work!?
  • How did QtCreator make it to version 3.6.1 before the developers realized they needed to check their pointers for null values before using them?
  • How did this bug sit there for two months before someone (me) finally dug into the gdb output?

I could go on, but the bottom line is this: This is the stable version! QtCreator 4.1.0 works great; I use it all the time. But since this bug is an upstream bug, 3.6.1 is going to sit there broken until 4.x.x is stabilized. I’m going to report the bug to upstream tomorrow, but seriously, you can’t tell me the Qt devs haven’t moved on from the 3.x.x series of Qt Creator by now. I sure hope anybody coming to Gentoo from another distro doesn’t need it anytime soon. This ought to put a bad taste in their mouths.


Those of you who don’t want to wait can apply the following user patch:


Leave a Reply