As additional KDE applications started to use KConfigWatcher, they started to crash on my laptop running Gentoo Linux. I was trying to patch them one by one to prevent the crashes. Then I realized that kconfig was built without dbus support on my system. After rebuilding kconfig with -DKCONFIG_USE_DBUS, the crashes went away. I looked into the source code of KConfigWatcher and discovered that its constructor initializes d->m_config only if KCONFIG_USE_DBUS is defined: https://github.com/KDE/kconfig/blob/491f5464/src/core/kconfigwatcher.cpp#L47 Consequently KConfigWatcher::config() may return nullptr, which triggers null dereference at caller's side, where a non-null value is expected. STEPS TO REPRODUCE 1. build kconfig without dbus support OBSERVED RESULT Applications like plasma or kwin start to crash. EXPECTED RESULT No crashes. SOFTWARE/OS VERSIONS Linux: 5.15.52-gentoo-x86_64 KDE Plasma Version: 5.24.5 KDE Frameworks Version: 5.92.0 Qt Version: 5.15.5 ADDITIONAL INFORMATION Previously reported with backtraces at: bug #423864 comment #4 bug #453242
Created attachment 150988 [details] [PATCH] KConfigWatcher: initialize d->m_config in constructor
I have submitted a merge request to fix this: https://invent.kde.org/frameworks/kconfig/-/merge_requests/134
The fix has been merged: https://invent.kde.org/frameworks/kconfig/-/commit/ed0ecf5b7640f0eca4aeba0e19cf173bc224585e