/usr/bin/muon-updater:11:QString:KConfig::name:KSharedConfig::openConfig:KSharedConfig::openConfig:Application::desktopContents

Bug #1317431 reported by errors.ubuntu.com bug bridge
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Muon
Fix Released
High
muon (Ubuntu)
Fix Released
Medium
Harald Sitter
Trusty
Fix Released
Medium
Harald Sitter
Utopic
Fix Released
Medium
Harald Sitter

Bug Description

[Impact]
libmuon's application backend (app-data based package listing) uses KSharedConfig to read the app-data desktop files, KSharedConfig however uses a global static object to manage sharing and this global static is not properly guarded against threaded access. This leads to semingly random crashes in muon-updater and muon-discover (also see bug #1317439 bug #1317440 bug #1317441). The proposed fix is to not use KSharedConfig and use KConfig directly as that is doing selfcontained file reading avoiding unguarded access to global statics and in general threads getting in the way of one another.

[Test Case]
Since this is a thread timing dependent bug we have to find a way to test whether the update fixes the crash. Giving all applications a good test run for a week should sufficiently prevent regressions though.
Monitoring errors.ubuntu is as good as it gets in terms of verifying the fix.

[Regression Potential]
Parsing of desktop file values could be broken which would render muon-discover useless.

[Other Info]
N/A

----

The Ubuntu Error Tracker has been receiving reports about a problem regarding muon. This problem was most recently seen with version 2.2.0-0ubuntu3, the problem page at https://errors.ubuntu.com/problem/aa2e03805593b7f94bf47b0fd1aca7ebeee8c9cb contains more details.

Tags: trusty utopic
Revision history for this message
In , anthony (anthonyc968) wrote :
Download full text (9.3 KiB)

Application: muon-updater (2.2.0)
KDE Platform Version: 4.13.0
Qt Version: 4.8.6
Operating System: Linux 3.13.0-24-generic x86_64
Distribution: Ubuntu 14.04 LTS

-- Information about the crash:
- What I was doing when the application crashed:

i opened muon Descover update when the application crashed unexpectedly

-- Backtrace:
Application: Muon Update Manager (muon-updater), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fe5367f17c0 (LWP 7645))]

Thread 5 (Thread 0x7fe522dc0700 (LWP 7646)):
#0 __libc_enable_asynccancel () at ../nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S:61
#1 0x00007fe533e436b2 in read () at ../sysdeps/unix/syscall-template.S:81
#2 0x00007fe530d52c20 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3 0x00007fe530d11b14 in g_main_context_check () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#4 0x00007fe530d11f7b in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#5 0x00007fe530d120ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#6 0x00007fe5345cb7be in QEventDispatcherGlib::processEvents (this=0x7fe51c0008c0, flags=...) at kernel/qeventdispatcher_glib.cpp:436
#7 0x00007fe53459d0af in QEventLoop::processEvents (this=this@entry=0x7fe522dbfde0, flags=...) at kernel/qeventloop.cpp:149
#8 0x00007fe53459d3a5 in QEventLoop::exec (this=this@entry=0x7fe522dbfde0, flags=...) at kernel/qeventloop.cpp:204
#9 0x00007fe534499c5f in QThread::exec (this=this@entry=0x10359c0) at thread/qthread.cpp:537
#10 0x00007fe53457e823 in QInotifyFileSystemWatcherEngine::run (this=0x10359c0) at io/qfilesystemwatcher_inotify.cpp:265
#11 0x00007fe53449c32f in QThreadPrivate::start (arg=0x10359c0) at thread/qthread_unix.cpp:349
#12 0x00007fe5311f1182 in start_thread (arg=0x7fe522dc0700) at pthread_create.c:312
#13 0x00007fe533e5230d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 4 (Thread 0x7fe521f88700 (LWP 7647)):
#0 0x00007fe533e49c33 in select () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007fe53457b171 in QProcessManager::run (this=0x7fe534905540 <processManager()::processManager>) at io/qprocess_unix.cpp:270
#2 0x00007fe53449c32f in QThreadPrivate::start (arg=0x7fe534905540 <processManager()::processManager>) at thread/qthread_unix.cpp:349
#3 0x00007fe5311f1182 in start_thread (arg=0x7fe521f88700) at pthread_create.c:312
#4 0x00007fe533e5230d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

Thread 3 (Thread 0x7fe518998700 (LWP 7658)):
[KCrash Handler]
#6 QString (other=<error reading variable: Cannot access memory at address 0x4318>, this=this@entry=0x7fe518997b40) at /usr/include/qt4/QtCore/qstring.h:725
#7 KConfig::name (this=0x4310) at ../../kdecore/config/kconfig.cpp:532
#8 0x00007fe5349b99b6 in KSharedConfig::openConfig (componentData=..., fileName=..., flags=..., resType=resType@entry=0x7fe521137640 "config") at ../../kdecore/config/ksharedconfig.cpp:46
#9 0x00007fe5349b9b5f in KSharedConfig::openConfig (fileName=..., flags=..., resType=resType@entry=0x7fe521137640 "config") at ../../kdecore/config/ksharedconfig.cpp:35
#10 0x00007fe521124a21 in Application::...

Read more...

Revision history for this message
In , Harald Sitter (apachelogger) wrote :

*** Bug 332038 has been marked as a duplicate of this bug. ***

Revision history for this message
In , Harald Sitter (apachelogger) wrote :

This is the cause of any and all KConfig crashes in muon applications.

The bug is ultimately caused by the Application backend which does the following out of the future'd init thread:
> KConfigGroup group = m_data->group("Desktop Entry");

m_data is:
> KSharedConfigPtr m_data;

from KSharedConfig::openConfig:
> const QList<KSharedConfig*> *list = globalSharedConfigList;

and the list is:
> K_GLOBAL_STATIC(QList<KSharedConfig*>, globalSharedConfigList)

since KSharedConfig is not thread safe what happens is that if a sharedconfig is accessed while the future init thread is running the globalSharedConfigList gets busted and crashes at a random later point in time.

the solution is to either not use a sharedconfig or move the config access out of the future thread and into a queued access via the mainloop.

furtheremore I am not actually sure the sharedconfig makes sense there since the application instance itself is a shared object, so there's probably nothing to be gained from using a sharedconfig there.

Revision history for this message
In , Aleix Pol (aleixpol-kde) wrote :

Git commit 70cc5d6532829d8bf1a95cd46ca5403eb195e6ec by Aleix Pol.
Committed on 07/05/2014 at 16:16.
Pushed by apol into branch '2.2'.

Fix threading problem involving KSharedConfig

Stop using it in favor of QSharedPointer<KConfig>, so that we don't access
the shared database, which is not thread-safe.

M +1 -6 libmuon/backends/ApplicationBackend/Application.cpp
M +1 -2 libmuon/backends/ApplicationBackend/Application.h

http://commits.kde.org/muon/70cc5d6532829d8bf1a95cd46ca5403eb195e6ec

Changed in muon (Ubuntu Trusty):
assignee: nobody → Harald Sitter (apachelogger)
importance: Undecided → Critical
importance: Critical → Medium
status: New → In Progress
Changed in muon (Ubuntu Utopic):
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Harald Sitter (apachelogger)
Changed in muon:
importance: Unknown → High
status: Unknown → Fix Released
description: updated
Changed in muon (Ubuntu Trusty):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package muon - 2.2.0-0ubuntu4

---------------
muon (2.2.0-0ubuntu4) utopic; urgency=medium

  * Add upstream_Fix-threading-problem-involving-KSharedConfig.patch
    + This should prevent unsafe cross thread KSharedConfig accesses leading
      to crashes in all muon applications that use the ApplicationBackend.
    LP: #1317431 LP: #1317439 LP: #1317440 LP: #1317441
 -- Harald Sitter <email address hidden> Thu, 08 May 2014 11:25:39 +0200

Changed in muon (Ubuntu Utopic):
status: Triaged → Fix Released
Revision history for this message
Scott Kitterman (kitterman) wrote : Please test proposed package

Hello errors.ubuntu.com, or anyone else affected,

Accepted muon into trusty-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/muon/2.2.0-0ubuntu3.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

tags: added: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package muon - 2.2.0-0ubuntu3.1

---------------
muon (2.2.0-0ubuntu3.1) trusty; urgency=medium

  * Add upstream_Fix-threading-problem-involving-KSharedConfig.patch
    + This should prevent unsafe cross thread KSharedConfig accesses leading
      to crashes in all muon applications that use the ApplicationBackend.
    LP: #1317431
 -- Harald Sitter <email address hidden> Thu, 08 May 2014 11:25:39 +0200

Changed in muon (Ubuntu Trusty):
status: Fix Committed → Fix Released
Revision history for this message
In , adaptee (adaptee) wrote :

*** Bug 320575 has been marked as a duplicate of this bug. ***

Revision history for this message
In , adaptee (adaptee) wrote :

*** Bug 334790 has been marked as a duplicate of this bug. ***

Revision history for this message
In , adaptee (adaptee) wrote :

*** Bug 320822 has been marked as a duplicate of this bug. ***

Mathew Hodson (mhodson)
tags: removed: verification-needed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.