Bug 439811

Summary: KStars crash when launched on Ubuntu 21.04
Product: [Applications] kstars Reporter: Anthony <anthony.hinsinger>
Component: generalAssignee: Jasem Mutlaq <mutlaqja>
Status: RESOLVED DOWNSTREAM    
Severity: normal CC: jrlangston11
Priority: NOR    
Version: git   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Anthony 2021-07-13 18:38:32 UTC
Kstars is installed from the indinightly repository, and crash when I launch it. 

OBSERVED RESULT

(gdb) file kstars
Reading symbols from kstars...
Reading symbols from /usr/lib/debug/.build-id/01/ff1cf9a10a79bc6ef59a8d010b883f962c92f8.debug...
(gdb) run
Starting program: /usr/bin/kstars 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
QApplication::qAppName: Please instantiate the QApplication object first
[New Thread 0x7fffef27b640 (LWP 42840)]

Thread 1 "kstars" received signal SIGSEGV, Segmentation fault.
0x00007ffff534e0be in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
(gdb) bt
#0  0x00007ffff534e0be in ?? () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#1  0x00007ffff56ed6e6 in QGuiApplication::screenAdded(QScreen*) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#2  0x00007ffff56d2ce0 in QWindowSystemInterface::handleScreenAdded(QPlatformScreen*, bool) () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#3  0x00007fffef5c9240 in QXcbConnection::initializeScreens() () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#4  0x00007fffef5a05f0 in QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#5  0x00007fffef5a3d63 in QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) () from /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#6  0x00007ffff7fbf513 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
#7  0x00007ffff56f1cbc in QGuiApplicationPrivate::createPlatformIntegration() () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#8  0x00007ffff56f31d8 in QGuiApplicationPrivate::createEventDispatcher() () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#9  0x00007ffff531d426 in QCoreApplicationPrivate::init() () from /lib/x86_64-linux-gnu/libQt5Core.so.5
#10 0x00007ffff56f6152 in QGuiApplicationPrivate::init() () from /lib/x86_64-linux-gnu/libQt5Gui.so.5
#11 0x00007ffff5e0dd0d in QApplicationPrivate::init() () from /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#12 0x000055555570bf6c in main (argc=<optimized out>, argv=0x7fffffffe128) at ./kstars/main.cpp:78


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Ubuntu 21.04
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 5.15.2
Comment 1 Jasem Mutlaq 2021-08-18 19:06:08 UTC
Thanks for the report. It doesn't look like it's related directly to KStars per se but some issue with Qt.
Comment 2 Anthony 2021-09-08 08:07:20 UTC
Yes, it seems to crash when it instanciate the QApplication. The strange thing is it only crash with kstars. I tried to compile a very simple apps with just a QApplication and it launch without any issue.
I've also tried to recompile the kstars-bleeding source package on my machine, the same crash happens.

Do you think it can be caused by some compilation options used by kstars ?

Thks,
Anthony.

Here is a more detailed backtrace (with qt debug symbols)

#0  doActivate<false> (sender=0x0, signal_index=9, argv=argv@entry=0x7fffffffd750) at kernel/qobject.cpp:3768
#1  0x00007ffff5345728 in QMetaObject::activate (sender=<optimized out>, m=m@entry=0x7ffff5c7e0a0 <QGuiApplication::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffffd750) at kernel/qobject.cpp:3946
#2  0x00007ffff56eb6e6 in QGuiApplication::screenAdded (this=<optimized out>, _t1=<optimized out>, _t1@entry=0x555556513360) at .moc/moc_qguiapplication.cpp:389
#3  0x00007ffff56d0ce0 in QWindowSystemInterface::handleScreenAdded (ps=ps@entry=0x555556504810, isPrimary=<optimized out>) at kernel/qwindowsysteminterface.cpp:826
#4  0x00007fffef947240 in QXcbConnection::initializeScreens (this=this@entry=0x5555564dbf00) at qxcbconnection_screens.cpp:413
#5  0x00007fffef91e5f0 in QXcbConnection::QXcbConnection (this=0x5555564dbf00, nativeInterface=<optimized out>, canGrabServer=<optimized out>, defaultVisualId=<optimized out>, displayName=<optimized out>) at qxcbconnection.cpp:103
#6  0x00007fffef921d63 in QXcbIntegration::QXcbIntegration (this=0x5555564d78c0, parameters=..., argc=<optimized out>, argv=<optimized out>) at qxcbintegration.cpp:197
#7  0x00007ffff7fbf513 in QXcbIntegrationPlugin::create (this=<optimized out>, system=..., argv=0x7fffffffe108, argc=@0x7fffffffddac: 1, parameters=...) at qxcbmain.cpp:56
#8  QXcbIntegrationPlugin::create (this=<optimized out>, system=..., parameters=..., argc=@0x7fffffffddac: 1, argv=0x7fffffffe108) at qxcbmain.cpp:53
#9  0x00007ffff56efcbc in init_platform (argv=<optimized out>, argc=@0x7fffffffddac: 1, platformThemeName=..., platformPluginPath=..., pluginNamesWithArguments=...) at kernel/qguiapplication.cpp:1223
#10 QGuiApplicationPrivate::createPlatformIntegration (this=0x5555564cd400) at kernel/qguiapplication.cpp:1481
#11 0x00007ffff56f11d8 in QGuiApplicationPrivate::createEventDispatcher (this=<optimized out>) at kernel/qguiapplication.cpp:1498
#12 0x00007ffff531b426 in QCoreApplicationPrivate::init (this=this@entry=0x5555564cd400) at kernel/qcoreapplication.cpp:834
#13 0x00007ffff56f4152 in QGuiApplicationPrivate::init (this=this@entry=0x5555564cd400) at kernel/qguiapplication.cpp:1527
#14 0x00007ffff5e0bd0d in QApplicationPrivate::init (this=0x5555564cd400) at kernel/qapplication.cpp:513
#15 0x000055555571599d in main (argc=<optimized out>, argv=0x7fffffffe108) at ./kstars/main.cpp:78
Comment 3 Anthony 2021-09-08 20:24:32 UTC
one more information, kstars crash with the same backtrace in ubuntu 21.10 (impish), the next stable release. Once again, I've not other Qt application crashing on thoses ubuntu versions.
A.
Comment 4 Anthony 2021-09-08 20:32:33 UTC
one more information, kstars (both stable and indinightly PPA) crash with the same backtrace in ubuntu 21.10 (impish), the next stable release. Once again, I've not other Qt application crashing on thoses ubuntu versions.
A.
Comment 5 Anthony 2021-09-10 14:50:52 UTC
Jasem,

I take some time to debug this problem. First, I've compile the source directly (using the same deps as the deb package) with a simple cmake/make ... and ho surprise, it works :)

So I 've tired to find differences in compilation options between the deb package and my build, and found the gulty one : LTO
Ubuntu has activated LTO by "default" since 21.04 (so dpkg-buildflags ouptut it) and I suspect Qt library or may be another kstars dependency lib is not using it.
So I've just added this to the debian/rules file (packaging/linux/debian/rules in your repo) :

export DEB_BUILD_MAINT_OPTIONS = optimize=-lto

It now works perfect !
I think you can add it without issue with old ubuntu version because it was already disabled by default. I'm adding a PR to the github repo, tell me if it's the right way.

Thanks again for you amazing app !

Anthony.
Comment 6 James 2021-09-10 23:46:51 UTC
I am using kstars 5.5.5 compiled nightly on Kubuntu 21.04 with no issues in this regard.  But I use the stable Indi sources compiled too, not nightly.  Hope this helps
Comment 7 James 2021-09-10 23:47:45 UTC
(In reply to James from comment #6)
> I am using kstars 5.5.5 compiled nightly on Kubuntu 21.04 with no issues in
> this regard.  But I use the stable Indi sources compiled too, not nightly. 
> Hope this helps

I mean Kstars 3.5.5 lol
Comment 8 Jasem Mutlaq 2022-03-14 10:50:46 UTC
Looks like this issue is not directly related to KStars per se, but packages downstream.