Bug 332530 - Muon crash when locking package at current version and pressing „Full upgrade”
Summary: Muon crash when locking package at current version and pressing „Full upgrade”
Status: RESOLVED FIXED
Alias: None
Product: muon
Classification: Applications
Component: muon (show other bugs)
Version: 2.1.3
Platform: Ubuntu Linux
: NOR crash
Target Milestone: ---
Assignee: Jonathan Thomas
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2014-03-24 22:00 UTC by Sergiu Bivol
Modified: 2016-03-03 08:59 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
use signal to catch when cache is reloaded (4.10 KB, patch)
2015-09-22 19:30 UTC, Carlo Vanini
Details
emit cache reload signal in libqapt (2.14 KB, patch)
2015-09-22 19:34 UTC, Carlo Vanini
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergiu Bivol 2014-03-24 22:00:00 UTC
Application: muon (2.1.3)
KDE Platform Version: 4.11.5
Qt Version: 4.8.4
Operating System: Linux 3.11.0-18-generic x86_64
Distribution: Ubuntu 13.10

-- Information about the crash:
- What I was doing when the application crashed:
I was in the „Review and apply changes” view, selected Firefox (currently installed from a PPA) and selected „Lock at current version” from the right-click menu.

Muon crashes if I press „Full upgrade” after that.

The crash can be reproduced every time.

-- Backtrace:
Application: Administratorul de pachete Muon (muon), signal: Segmentation fault
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fc1525607c0 (LWP 7243))]

Thread 2 (Thread 0x7fc137fff700 (LWP 7248)):
#0  0x00007fc14f384f7d in poll () at ../sysdeps/unix/syscall-template.S:81
#1  0x00007fc14b1766a4 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007fc14b1767ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007fc14fb0aa76 in QEventDispatcherGlib::hasPendingEvents (this=<optimized out>) at kernel/qeventdispatcher_glib.cpp:449
#4  0x00007fc1300028e0 in ?? ()
#5  0x00007fc137ffed10 in ?? ()
#6  0x00007fc137ffed60 in ?? ()
#7  0x00007fc137ffed10 in ?? ()
#8  0x00000000022c2c60 in ?? ()
#9  0x0000000000001000 in ?? ()
#10 0x00007fc14fadc5ef in QEventLoop::processEvents (this=this@entry=0x7fc137ffed70, flags=<error reading variable: Cannot access memory at address 0x1>) at kernel/qeventloop.cpp:149
#11 0x00007fc14fadc8e5 in QEventLoop::exec (this=this@entry=0x7fc137ffed70, flags=...) at kernel/qeventloop.cpp:204
#12 0x00007fc14f9db88f in QThread::exec (this=this@entry=0x2374380) at thread/qthread.cpp:542
#13 0x00007fc14fabdd13 in QInotifyFileSystemWatcherEngine::run (this=0x2374380) at io/qfilesystemwatcher_inotify.cpp:265
#14 0x00007fc14f9ddf2f in QThreadPrivate::start (arg=0x2374380) at thread/qthread_unix.cpp:338
#15 0x00007fc14b64ef6e in start_thread (arg=0x7fc137fff700) at pthread_create.c:311
#16 0x00007fc14f3919cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

Thread 1 (Thread 0x7fc1525607c0 (LWP 7243)):
[KCrash Handler]
#6  0x00007fc151833064 in QApt::Backend::cache (this=0x7fc14fe3db50 <vtable for QObjectPrivate+16>) at /build/buildd/qapt-2.0.65/src/backend.cpp:310
#7  0x00007fc1518408a0 in QApt::Package::shortDescription (this=this@entry=0x30833f0) at /build/buildd/qapt-2.0.65/src/package.cpp:264
#8  0x000000000042749d in PackageModel::data (this=<optimized out>, index=..., role=<optimized out>) at /build/buildd/muon-2.1.3/muon/PackageModel/PackageModel.cpp:60
#9  0x00007fc150a42ec3 in QSortFilterProxyModel::data(QModelIndex const&, int) const () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#10 0x00000000004285f2 in data (arole=34, this=0x7fff1b06c590) at /usr/include/qt4/QtCore/qabstractitemmodel.h:402
#11 PackageDelegate::sizeHint (this=0x246a120, option=..., index=...) at /build/buildd/muon-2.1.3/muon/PackageModel/PackageDelegate.cpp:256
#12 0x00007fc150a00e2e in QTreeView::indexRowSizeHint(QModelIndex const&) const () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#13 0x00007fc150a0d0ed in QTreeView::dataChanged(QModelIndex const&, QModelIndex const&) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#14 0x00007fc14faf1a58 in QMetaObject::activate (sender=0x2487120, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff1b06c810) at kernel/qobject.cpp:3539
#15 0x00007fc14fb3b587 in QAbstractItemModel::dataChanged (this=0x7fc14fe3db50 <vtable for QObjectPrivate+16>, _t1=..., _t2=...) at .moc/release-shared/moc_qabstractitemmodel.cpp:163
#16 0x00007fc150a49be9 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#17 0x00007fc14faf1a58 in QMetaObject::activate (sender=0x2490a20, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff1b06ca90) at kernel/qobject.cpp:3539
#18 0x00007fc14fb3b587 in QAbstractItemModel::dataChanged (this=0x7fc14fe3db50 <vtable for QObjectPrivate+16>, this@entry=0x2490a20, _t1=..., _t2=...) at .moc/release-shared/moc_qabstractitemmodel.cpp:163
#19 0x00000000004277ab in PackageModel::externalDataChanged (this=0x2490a20) at /build/buildd/muon-2.1.3/muon/PackageModel/PackageModel.cpp:107
#20 0x00007fc14faf1a58 in QMetaObject::activate (sender=0x27518e0, m=m@entry=0x7fc151a77640 <QApt::Backend::staticMetaObject>, local_signal_index=local_signal_index@entry=0, argv=argv@entry=0x0) at kernel/qobject.cpp:3539
#21 0x00007fc1518616e0 in QApt::Backend::packageChanged (this=<optimized out>) at /build/buildd/qapt-2.0.65/obj-x86_64-linux-gnu/src/moc_backend.cxx:207
#22 0x00007fc151833e42 in QApt::Backend::markPackagesForDistUpgrade (this=<optimized out>) at /build/buildd/qapt-2.0.65/src/backend.cpp:891
#23 0x000000000041cd6d in MainWindow::markDistUpgrade (this=0x247c320) at /build/buildd/muon-2.1.3/muon/MainWindow.cpp:240
#24 0x000000000041aa05 in MainWindow::qt_static_metacall (_o=<optimized out>, _id=<optimized out>, _a=<optimized out>, _c=<optimized out>) at /build/buildd/muon-2.1.3/obj-x86_64-linux-gnu/muon/moc_MainWindow.cpp:96
#25 0x00007fc14faf1a58 in QMetaObject::activate (sender=0x27600d0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff1b06cdf0) at kernel/qobject.cpp:3539
#26 0x00007fc1504c8a32 in QAction::triggered(bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#27 0x00007fc1504ca403 in QAction::activate(QAction::ActionEvent) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#28 0x00007fc1508810a2 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#29 0x00007fc1508811cc in QAbstractButton::mouseReleaseEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#30 0x00007fc150937d9a in QToolButton::mouseReleaseEvent(QMouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#31 0x00007fc15051e31e in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#32 0x00007fc1504cedfc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#33 0x00007fc1504d55ad in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#34 0x00007fc1511d8a6a in KApplication::notify (this=0x7fff1b06db50, receiver=0x2798a00, event=0x7fff1b06d2f0) at ../../kdeui/kernel/kapplication.cpp:311
#35 0x00007fc14fadd8bd in QCoreApplication::notifyInternal (this=0x7fff1b06db50, receiver=0x2798a00, event=0x7fff1b06d2f0) at kernel/qcoreapplication.cpp:946
#36 0x00007fc1504d4d63 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#37 0x00007fc1505497db in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#38 0x00007fc150549079 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#39 0x00007fc150570922 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#40 0x00007fc14b1763b6 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#41 0x00007fc14b176708 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#42 0x00007fc14b1767ac in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#43 0x00007fc14fb0aa55 in operator= (f=<synthetic pointer>, this=0x22f4120) at ../../include/QtCore/../../src/corelib/global/qglobal.h:2316
#44 QEventDispatcherGlib::processEvents (this=0x22c4100, flags=...) at kernel/qeventdispatcher_glib.cpp:438
#45 0x00007fc1505709d6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#46 0x00007fc14fadc5ef in QEventLoop::processEvents (this=this@entry=0x7fff1b06da50, flags=...) at kernel/qeventloop.cpp:149
#47 0x00007fc14fadc8e5 in QEventLoop::exec (this=this@entry=0x7fff1b06da50, flags=...) at kernel/qeventloop.cpp:204
#48 0x00007fc14fae1e5b in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1218
#49 0x000000000041a05b in main (argc=1, argv=0x7fff1b06dc88) at /build/buildd/muon-2.1.3/muon/main.cpp:56

Reported using DrKonqi
Comment 1 Carlo Vanini 2015-09-22 19:30:02 UTC
Created attachment 94681 [details]
use signal to catch when cache is reloaded

After some debugging, here is my view on the problem. First some facts:
- PackageWidget uses a PackageModel, which keeps an internal list of (pointers to) packages
- pinning/un-pinning a package causes the apt cache to be reloaded by the backend
- reloading the cache means that all Package objects are deleted, and new ones are created

When a package is (un-)pinned through the right-click menu for instance, the widget where we request the action knows it has to reset itself and clear its model. If we do this in the "review changes" tab instead of the "package manager" tab, we have two existing instances of PackageWidget: one for each tab, although only one is visible. The problem is that only the widget in "review changes" does reset itself (i.e. the one where we click), the other one will keep pointers and iterators to old objects.

The patch proposed here uses signals to get notified when the cache is reloaded. But it requires patching libqapt to emit those signals.

Alternatives:
- destroy "package manager" when "review changes" is shown, and always have only one PackageWidget at a time
- disable package status changes in "review changes"

Issues still open after patching:
- search box keeps text after reload, but filter is cleared
- after cache reload any change (install/uninstall/purge/...) is reset
Comment 2 Carlo Vanini 2015-09-22 19:34:07 UTC
Created attachment 94682 [details]
emit cache reload signal in libqapt

This is the change required in libqapt for the muon patch to work
Comment 3 Carlo Vanini 2016-03-03 08:59:11 UTC
Git commit a437d39e43112a3e61ebafadd4e3a06b9bd91437 by Carlo Vanini.
Committed on 03/03/2016 at 08:53.
Pushed by vanini into branch 'master'.

Connect to backend signals to catch cache reload.

When the cache is reloaded libqapt deletes Package objects and creates them
anew. This results in dangling pointers in muon models.

When "Preview Changes" is shown we have two models with lists of packages, and
both should be cleared and repopulated.

The cache reload can be triggered by pinning/unpinning (lock/unlock) a package.

REVIEW: 127107

M  +2    -0    src/MainWindow.cpp
M  +13   -1    src/PackageModel/PackageWidget.cpp
M  +2    -0    src/PackageModel/PackageWidget.h
M  +2    -0    src/StatusWidget.cpp

http://commits.kde.org/muon/a437d39e43112a3e61ebafadd4e3a06b9bd91437