Bug 432949

Summary: Crash on startup with KDNSSD 5.79.0
Product: [Frameworks and Libraries] frameworks-kdnssd Reporter: Sefa Eyeoglu <contact>
Component: generalAssignee: Matthew Dawson <matthew>
Status: RESOLVED FIXED    
Severity: crash CC: arojas, kalindgar, kdelibs-bugs, kossebau
Priority: NOR    
Version: 5.79.0   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Sefa Eyeoglu 2021-02-14 21:07:50 UTC
SUMMARY
Starting KTorrent with KDNSSD 5.79.0 installed causes a crash on startup.

Rebuilding against 5.79.0 does not help. Git master also does not work.

STEPS TO REPRODUCE
1. Install ktorrent=20.12.2 and kdnssd=5.79.0
2. Start ktorrent

OBSERVED RESULT
Application: KTorrent (ktorrent), signal: Segmentation fault

[KCrash Handler]
#4  0x00007f6d400666e3 in std::__atomic_base<int>::load(std::memory_order) const (__m=std::memory_order_relaxed, this=0x65007200620000) at /usr/include/c++/10.2.0/bits/atomic_base.h:426
#5  QAtomicOps<int>::loadRelaxed<int>(std::atomic<int> const&) (_q_value=...) at /usr/include/qt/QtCore/qatomic_cxx11.h:239
#6  QBasicAtomicInteger<int>::loadRelaxed() const (this=0x65007200620000) at /usr/include/qt/QtCore/qbasicatomic.h:107
#7  QtPrivate::RefCount::deref() (this=0x65007200620000) at /usr/include/qt/QtCore/qrefcount.h:66
#8  QString::~QString() (this=0x7ffec4cb5fc0, __in_chrg=<optimized out>) at /usr/include/qt/QtCore/qstring.h:1307
#9  0x00007f6d40070057 in QString::operator=(char const*) (ch=0x7f6d4007cb88 "local.", this=0x56068d2b1ce8) at /usr/include/qt/QtCore/qstring.h:275
#10 KDNSSD::PublicService::PublicService(QString const&, QString const&, unsigned int, QString const&, QStringList const&) (this=0x56068ca6ed30, name=..., type=<optimized out>, port=3301662656, domain=..., subtypes=...) at /usr/src/debug/kdnssd-5.79.0/src/avahi-publicservice.cpp:33
#11 0x00007f6d400ccd23 in kt::TorrentService::start() () at /usr/lib/qt/plugins/ktorrent/ktorrent_zeroconf.so
#12 0x00007f6da17a2696 in  () at /usr/lib/libKF5Torrent.so.6
#13 0x00007f6da17ac966 in bt::TorrentControl::continueStart() () at /usr/lib/libKF5Torrent.so.6
#14 0x00007f6da18d28d2 in kt::QueueManager::startSafely(bt::TorrentInterface*) () at /usr/lib/libktcore.so.16
#15 0x00007f6da18d2965 in kt::QueueManager::startInternal(bt::TorrentInterface*) () at /usr/lib/libktcore.so.16
#16 0x00007f6da18d475e in kt::QueueManager::orderQueue() () at /usr/lib/libktcore.so.16
#17 0x000056068a4fe60e in kt::Core::delayedStart() ()
#18 0x00007f6d9fc16532 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#19 0x00007f6da06b1752 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#20 0x00007f6d9fbe9a2a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#21 0x00007f6d9fbec523 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5
#22 0x00007f6d9fc43054 in  () at /usr/lib/libQt5Core.so.5
#23 0x00007f6d9dc63b84 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#24 0x00007f6d9dcb7c21 in  () at /usr/lib/libglib-2.0.so.0
#25 0x00007f6d9dc623b1 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#26 0x00007f6d9fc42691 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#27 0x00007f6d9fbe83ac in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#28 0x00007f6d9fbf0844 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#29 0x000056068a4f44cc in main ()
[Inferior 1 (process 245785) detached]


EXPECTED RESULT
yes.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.20.90
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Kernel Version: 5.10.15-zen2-1-zen
OS Type: 64-bit
Processors: 24 × AMD Ryzen 9 3900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: Radeon RX Vega

ADDITIONAL INFORMATION
Comment 1 Sefa Eyeoglu 2021-02-14 21:10:22 UTC
Looks like knotes has a similar issue. This might be an issue with kdnssd
Comment 2 Antonio Rojas 2021-02-14 21:22:32 UTC
Looks related to e8f082950a2fcb7b148a1ac568eda9400145da5d
Comment 3 Friedrich W. H. Kossebau 2021-02-14 21:49:32 UTC
Mh, reinterpret_cast vs. static_cast with a multi-heritance subclass... I screwed up  here I suspect after a first quick look.

Seems e8f082950a2fcb7b148a1ac568eda9400145da5d needs to be reverted indeed, taking care now to look more at it and then get this official later tonight.
Comment 4 Bug Janitor Service 2021-02-14 22:47:09 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kdnssd/-/merge_requests/3
Comment 5 Friedrich W. H. Kossebau 2021-02-15 16:09:50 UTC
Git commit 8c14803908a2a718fa0716fb98506aebda1fed46 by Friedrich W. H. Kossebau.
Committed on 15/02/2021 at 14:30.
Pushed by kossebau into branch 'master'.

Revert "Switch from custom K_D to Q_DECLARE_PRIVATE_D & Q_D"

Q_DECLARE_PRIVATE_D uses reinterpret_cast with the d member in the
defined methods, which results in bad casting with the multi-inheritance
subclasses of ServiceBasePrivate.

Switch to use KDNSSD_D instead of K_D to reduce risk of potential clashes.

This reverts commit e8f082950a2fcb7b148a1ac568eda9400145da5d.

M  +12   -12   src/avahi-publicservice.cpp
M  +2    -0    src/avahi-publicservice_p.h
M  +3    -3    src/avahi-remoteservice.cpp
M  +2    -0    src/avahi-remoteservice_p.h
M  +14   -12   src/mdnsd-publicservice.cpp
M  +5    -3    src/mdnsd-remoteservice.cpp
M  +0    -1    src/publicservice.h
M  +0    -1    src/remoteservice.h
M  +0    -14   src/servicebase.cpp
M  +6    -1    src/servicebase.h

https://invent.kde.org/frameworks/kdnssd/commit/8c14803908a2a718fa0716fb98506aebda1fed46
Comment 6 Antonio Rojas 2021-02-16 07:35:36 UTC
*** Bug 432993 has been marked as a duplicate of this bug. ***