Public bug reported:
Twinkle segfaults immediately on startup on Ubuntu 26.04, before any
window is shown.
Versions:
- Ubuntu 26.04 (resolute), amd64
- twinkle 1:1.10.3+dfsg-2
- libqt5core5t64 5.15.18+dfsg-1ubuntu1
Steps to reproduce:
1. Install twinkle
2. Run `twinkle`
Expected: the main window opens.
Actual:
Must construct a QGuiApplication first.
QObject::connect: Cannot connect (nullptr)::cursorRectangleChanged() to
QIBusPlatformInputContext::cursorRectChanged()
Segmentation fault (core dumped)
dmesg: segfault at 8 ... error 4 in libQt5Core.so.5.15.18 (null pointer
read)
The crash is identical with QT_QPA_PLATFORM=wayland, xcb and offscreen,
with a clean environment (env -i), and with an empty ~/.twinkle.
A minimal PyQt5 QApplication works fine on the same system.
Backtrace (debuginfod):
#0 ?? () from libQt5Core.so.5
#1 QGuiApplication::screenAdded(QScreen*) () from libQt5Gui.so.5
...
#29 QApplicationPrivate::init() () from libQt5Widgets.so.5
#30 t_twinkle_application::t_twinkle_application (...) at
src/gui/twinkleapplication.cpp:31
#31 create_user_interface (...) at src/gui/main.cpp:511
#32 main (...) at src/gui/main.cpp:699
Root cause:
The twinkle executable contains a copy relocation for QCoreApplication::self:
$ readelf -rW /usr/bin/twinkle | grep QCoreApplication4self
R_X86_64_COPY _ZN16QCoreApplication4selfE@Qt_5 + 0
QtCore sets its own copy of `self` during QApplication construction, while
QtGui reads the executable's copy, which stays NULL. qGuiApp is therefore
NULL during init ("Must construct a QGuiApplication first"), and emitting
screenAdded() on a null object crashes. Qt 5 requires applications to be
built with -fPIC (not -fPIE) for this reason.
Fix (verified locally):
Rebuilding the package with -fPIC fixes the crash:
DEB_CXXFLAGS_APPEND="-fPIC" dpkg-buildpackage -us -uc -b
The rebuilt binary uses R_X86_64_GLOB_DAT instead of R_X86_64_COPY for
QCoreApplication::self, and Twinkle starts normally. Adding -fPIC to the
CXXFLAGS in debian/rules (e.g. DEB_CXXFLAGS_MAINT_APPEND = -fPIC) should
fix the package.
** Affects: twinkle (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2172027
Title:
twinkle crashes on startup: QCoreApplication::self copy-relocated in
PIE binary (needs -fPIC)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/twinkle/+bug/2172027/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs