Bug 386353 - Crash on startup, related to Util::Css::warningBorder
Summary: Crash on startup, related to Util::Css::warningBorder
Status: RESOLVED FIXED
Alias: None
Product: trojita
Classification: Applications
Component: Desktop GUI (other bugs)
Version First Reported In: git
Platform: Compiled Sources OpenBSD
: NOR normal
Target Milestone: ---
Assignee: Trojita default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-30 12:19 UTC by Caspar Schutijser
Modified: 2017-11-02 19:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Caspar Schutijser 2017-10-30 12:19:16 UTC
Trojita currently crashes on startup on my machine (OpenBSD current on amd64, clang 5.0.0). The back trace:

$ egdb _build/trojita
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-openbsd6.2".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from _build/trojita...done.
(gdb) r
Starting program: /home/caspar/src/trojita/_build/trojita 

Program received signal SIGSEGV, Segmentation fault.
0x00001f50a730a262 in std::__1::__atomic_base<int, false>::load (this=0x0, __m=std::__1::memory_order_relaxed) at /usr/include/c++/v1/atomic:894
894             {return __c11_atomic_load(&__a_, __m);}
(gdb) bt full
#0  0x00001f50a730a262 in std::__1::__atomic_base<int, false>::load (this=0x0, __m=std::__1::memory_order_relaxed) at /usr/include/c++/v1/atomic:894
No locals.
#1  QAtomicOps<int>::load<int> (_q_value=...) at /usr/local/include/X11/qt5/QtCore/qatomic_cxx11.h:227
No locals.
#2  0x00001f50a730a1e5 in QBasicAtomicInteger<int>::load (this=0x0) at /usr/local/include/X11/qt5/QtCore/qbasicatomic.h:102
No locals.
#3  0x00001f50a730a549 in QtPrivate::RefCount::ref (this=0x0) at /usr/local/include/X11/qt5/QtCore/qrefcount.h:55
        count = 8016
#4  0x00001f50a7309f22 in QString::QString (this=0x1f50a7b7ff40 <Gui::SettingsDialog::warningStyleSheet>, other=...) at /usr/local/include/X11/qt5/QtCore/qstring.h:907
No locals.
#5  0x00001f50a7358a6e in QStringBuilder<QString, QString>::operator QString (this=0x7f7ffffda648) at /usr/local/include/X11/qt5/QtCore/qstringbuilder.h:147
        r = {static null = {<No data fields>}, d = 0x0}
#6  0x00001f50a7401f00 in __cxx_global_var_init () at /home/caspar/src/trojita/src/Gui/SettingsDialog.cpp:67
No locals.
#7  0x00001f50a7412ed9 in _GLOBAL__sub_I_SettingsDialog.cpp () at /usr/local/include/X11/qt5/QtWidgets/qwidget.h:790
        Gui::SettingsDialog::warningStyleSheet = {static null = {<No data fields>}, d = 0x0}
#8  0x00001f50a7307662 in ?? ()
No symbol table info available.
#9  0x00001f50a7300399 in __init ()
No symbol table info available.
#10 0x00007f7ffffda6e0 in ?? ()
No symbol table info available.
#11 0x00001f50a73075a6 in _start ()
No symbol table info available.
(gdb)


Using git bisect, I identified the commit that introduced the problem: commit f70690899d2a6c69495d225214a7279ba8c1ff73, https://cgit.kde.org/trojita.git/commit/?id=f70690899d2a6c69495d225214a7279ba8c1ff73
Right now I'm using the patch at the bottom as a workaround. That's obviously not a proper fix but it demonstrates that the way Util::Css::warningBorder is used causes the problem. How can we fix this properly?

https://bugs.kde.org/show_bug.cgi?id=386351 is probably the same problem as the diff below works for miqlas as well.

diff --git a/src/Gui/SettingsDialog.cpp b/src/Gui/SettingsDialog.cpp
index 6535caff..d9c4c44d 100644
--- a/src/Gui/SettingsDialog.cpp
+++ b/src/Gui/SettingsDialog.cpp
@@ -63,7 +63,8 @@
 namespace Gui
 {
 
-QString SettingsDialog::warningStyleSheet = Util::Css::warningBorder + QStringLiteral("font-weight: bold;");
+QString SettingsDialog::warningStyleSheet = QStringLiteral("font-weight: bold;");
 
 /** @short Check a text field for being non empty. If it's empty, show an error to the user. */
 template<typename T>
Comment 1 Thomas Lübking 2017-10-30 13:16:35 UTC
Try chaning src/Gui/Util.cpp to
const QString Css::warningBorder = QString::fromLatin1("border: 2px solid red; background-color: #E7C575; color: black; padding: 5px; margin: 5px; text-align: center;");
Comment 2 Jan Kundrát 2017-10-30 13:21:23 UTC
*** Bug 386351 has been marked as a duplicate of this bug. ***
Comment 3 Caspar Schutijser 2017-10-30 13:28:23 UTC
(In reply to Thomas Lübking from comment #1)
> Try chaning src/Gui/Util.cpp to
> const QString Css::warningBorder = QString::fromLatin1("border: 2px solid
> red; background-color: #E7C575; color: black; padding: 5px; margin: 5px;
> text-align: center;");

Thanks for your suggestion. I changed it but unfortunately it still crashes with a similar back trace.
Comment 4 Caspar Schutijser 2017-10-30 13:43:46 UTC
(In reply to Caspar Schutijser from comment #3)
> (In reply to Thomas Lübking from comment #1)
> > Try chaning src/Gui/Util.cpp to
> > const QString Css::warningBorder = QString::fromLatin1("border: 2px solid
> > red; background-color: #E7C575; color: black; padding: 5px; margin: 5px;
> > text-align: center;");
> 
> Thanks for your suggestion. I changed it but unfortunately it still crashes
> with a similar back trace.

jkt pointed me to this: https://isocpp.org/wiki/faq/ctors#static-init-order

I'm working on a patch to fix the problem using the "Construct On First Use Idiom".
Comment 5 Caspar Schutijser 2017-10-30 13:56:20 UTC
(In reply to Caspar Schutijser from comment #4)
> I'm working on a patch to fix the problem using the "Construct On First Use
> Idiom".

See https://gerrit.vesnicky.cesnet.cz/r/951
Comment 6 Caspar Schutijser 2017-11-02 19:38:58 UTC
Git commit 4c02000a91f499dcd9caf5a3d77cd6fd2d2734fe by Caspar Schutijser.
Committed on 30/10/2017 at 14:10.
Pushed by gerrit into branch 'master'.

Apply "Construct On First Use Idiom" to warningBorder

It suffered from the "static initialization order fiasco" [1], as
pointed out by Jan, which was accidentally introduced by
commit f70690899d2a6c69495d225214a7279ba8c1ff73. First reported by
miqlas on IRC.

1: https://isocpp.org/wiki/faq/ctors#static-init-order
Related: bug 386351

Change-Id: I559c12e606883068e09072de26bdaac3b1d5d73c

M  +1    -1    src/Gui/ComposeWidget.cpp
M  +1    -1    src/Gui/SettingsDialog.cpp
M  +5    -1    src/Gui/Util.cpp
M  +1    -3    src/Gui/Util.h

https://commits.kde.org/trojita/4c02000a91f499dcd9caf5a3d77cd6fd2d2734fe