Bug 364141

Summary: Kmix crashes when trying to change the volume for individual streams with scrollwheel from systray
Product: [Applications] kmix Reporter: Uģis <esesmu>
Component: generalAssignee: Christian Esken <esken>
Status: RESOLVED FIXED    
Severity: crash CC: asturm, azamat.hackimov, cfeck, johannes.hirte, johu, josef64, kensington, nuklea, raphaelbastos, rdieter, tlinux, whatifgodwasoneofus, xunilhcra, zaz
Priority: NOR    
Version: 4.5   
Target Milestone: ---   
Platform: Chakra   
OS: Linux   
URL: https://git.reviewboard.kde.org/r/128546/
Latest Commit: Version Fixed In:
Attachments: gdb bt
Fix-for-crashing-on-mousewheel-event-bug-364141.patch

Description Uģis 2016-06-09 11:39:51 UTC
Kmix crashes when trying to change the volume for individual streams with scrollwheel. If I drag the sliders with leftclick everything is fine. So it seems something is wrong how scrolling is handled. This started to happen after I updated to latest kf5 and qt

Reproducible: Always

Steps to Reproduce:
1. Open kmix
2. Try to change the volume of some stream with scrollwheel

Actual Results:  
Kmix crashed. If I have volume feedback enabled it will also lock up the entire plasma before it crashes

Expected Results:  
Volume should be adjusted

Plasma: 5.6.4

Name           : kcmutils
Version        : 5.23.0-1

Name           : kdelibs4support
Version        : 5.23.0-1

Name           : libcanberra
Version        : 0.30-3

Name           : plasma-framework
Version        : 5.23.0-1

Qt: 5.6.1
Comment 1 Christoph Feck 2016-06-12 12:18:32 UTC
Are you sure you are using "kmix"? Newer Plasma versions use "plasma-pa" as a replacement.

Please add the backtrace for the crash. For more information, please see https://techbase.kde.org/Development/Tutorials/Debugging/How_to_create_useful_crash_reports
Comment 2 Uģis 2016-06-12 12:41:34 UTC
This is all I could get from gdb, unfortunately I don't get the kde crash handler when the crash happens, am I missing some package? not sure

-----------------
(gdb) run --nofork --nocrashhandler -v
Starting program: /usr/bin/kmix --nofork --nocrashhandler -v
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Qt: 5.6.1
KDE Frameworks: 5.23.0
KMix: 4.6
[Inferior 1 (process 1648) exited normally]
(gdb) run --nofork --nocrashhandler
Starting program: /usr/bin/kmix --nofork --nocrashhandler
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe4bed700 (LWP 1652)]
kf5.kcoreaddons.kaboutdata: Could not initialize the equivalent properties of Q*Application: no instance (yet) existing.
[New Thread 0x7fffde9fe700 (LWP 1653)]
kf5.kcoreaddons.kaboutdata: QCoreApplication::applicationVersion "" is out-of-sync with KAboutData::applicationData().version "4.6"
kf5.kcoreaddons.kaboutdata: QGuiApplication::applicationDisplayName "kmix" is out-of-sync with KAboutData::applicationData().displayName "KMix"
kf5.kcoreaddons.kaboutdata: QGuiApplication::desktopFileName "" is out-of-sync with KAboutData::applicationData().desktopFileName "org.kde.kmix"
Shortcut for action  "hide_kmixwindow" "Hide Mixer Window" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "save_1" "Save volume profile 1" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "save_2" "Save volume profile 2" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "save_3" "Save volume profile 3" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "save_4" "Save volume profile 4" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "load_1" "Load volume profile 1" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "load_2" "Load volume profile 2" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "load_3" "Load volume profile 3" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Shortcut for action  "load_4" "Load volume profile 4" set with QAction::setShortcut()! Use KActionCollection::setDefaultShortcut(s) instead.
Your code needs to be ported in KF5.  See the Ki18n programmers guide.
Cannot load profile  "PulseAudio.Playback_Devices.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Capture_Devices.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Playback_Streams.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Capture_Streams.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Playback_Devices.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Capture_Devices.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Playback_Streams.1.default"  . It was removed by the user, or the KMix config file is defective.
Cannot load profile  "PulseAudio.Capture_Streams.1.default"  . It was removed by the user, or the KMix config file is defective.

Program received signal SIGSEGV, Segmentation fault.
0x00007fffefe0abbb in g_main_context_wakeup () from /usr/lib/libglib-2.0.so.0
Comment 3 Uģis 2016-06-12 12:54:05 UTC
Valgrind

-------------

==1941== Memcheck, a memory error detector
==1941== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==1941== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==1941== Command: kmix
==1941== Parent PID: 12997
==1941== 
==1941== 
==1941== HEAP SUMMARY:
==1941==     in use at exit: 100,783 bytes in 171 blocks
==1941==   total heap usage: 844 allocs, 673 frees, 156,998 bytes allocated
==1941== 
==1941== LEAK SUMMARY:
==1941==    definitely lost: 0 bytes in 0 blocks
==1941==    indirectly lost: 0 bytes in 0 blocks
==1941==      possibly lost: 0 bytes in 0 blocks
==1941==    still reachable: 100,783 bytes in 171 blocks
==1941==         suppressed: 0 bytes in 0 blocks
==1941== Rerun with --leak-check=full to see details of leaked memory
==1941== 
==1941== For counts of detected and suppressed errors, rerun with: -v
==1941== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==1942== Syscall param writev(vector[...]) points to uninitialised byte(s)
==1942==    at 0x51D484D: ??? (in /usr/lib/libc-2.22.so)
==1942==    by 0xE261DA8: ??? (in /usr/lib/libxcb.so.1.1.0)
==1942==    by 0xE26219C: ??? (in /usr/lib/libxcb.so.1.1.0)
==1942==    by 0xE2628F6: ??? (in /usr/lib/libxcb.so.1.1.0)
==1942==    by 0xE262AC3: xcb_flush (in /usr/lib/libxcb.so.1.1.0)
==1942==    by 0x190870E5: QXcbWindow::hide() (in /usr/lib/libQt5XcbQpa.so.5.6.1)
==1942==    by 0x8739A7E: QWindow::setVisible(bool) (in /usr/lib/libQt5Gui.so.5.6.1)
==1942==    by 0x81631E6: QWidgetPrivate::hide_sys() (in /usr/lib/libQt5Widgets.so.5.6.1)
==1942==    by 0x816AA4C: QWidgetPrivate::hide_helper() (in /usr/lib/libQt5Widgets.so.5.6.1)
==1942==    by 0x816F40F: QWidget::setVisible(bool) (in /usr/lib/libQt5Widgets.so.5.6.1)
==1942==    by 0x8170676: QWidget::setParent(QWidget*, QFlags<Qt::WindowType>) (in /usr/lib/libQt5Widgets.so.5.6.1)
==1942==    by 0x817174B: QWidget::setParent(QWidget*) (in /usr/lib/libQt5Widgets.so.5.6.1)
==1942==  Address 0x180da529 is 4,537 bytes inside a block of size 21,152 alloc'd
==1942==    at 0x4C2AC85: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1942==    by 0xE26175B: xcb_connect_to_fd (in /usr/lib/libxcb.so.1.1.0)
==1942==    by 0xE265490: xcb_connect_to_display_with_auth_info (in /usr/lib/libxcb.so.1.1.0)
==1942==    by 0x9FB74E9: _XConnectXCB (in /usr/lib/libX11.so.6.3.0)
==1942==    by 0x9FA81E1: XOpenDisplay (in /usr/lib/libX11.so.6.3.0)
==1942==    by 0x1906F98C: QXcbConnection::QXcbConnection(QXcbNativeInterface*, bool, unsigned int, char const*) (in /usr/lib/libQt5XcbQpa.so.5.6.1)
==1942==    by 0x190755C4: QXcbIntegration::QXcbIntegration(QStringList const&, int&, char**) (in /usr/lib/libQt5XcbQpa.so.5.6.1)
==1942==    by 0x40244DC: ??? (in /usr/lib/qt5/plugins/platforms/libqxcb.so)
==1942==    by 0x8719E1E: QPlatformIntegrationFactory::create(QString const&, QStringList const&, int&, char**, QString const&) (in /usr/lib/libQt5Gui.so.5.6.1)
==1942==    by 0x8728562: QGuiApplicationPrivate::createPlatformIntegration() (in /usr/lib/libQt5Gui.so.5.6.1)
==1942==    by 0x872938C: QGuiApplicationPrivate::createEventDispatcher() (in /usr/lib/libQt5Gui.so.5.6.1)
==1942==    by 0x8E43AA9: QCoreApplicationPrivate::init() (in /usr/lib/libQt5Core.so.5.6.1)
==1942== 
==1942== Stack overflow in thread 1: can't grow stack to 0xffe801fe0
==1942== 
==1942== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==1942==  Access not within mapped region at address 0xFFE801FE0
==1942==    at 0xCB89BBB: g_main_context_wakeup (in /usr/lib/libglib-2.0.so.0.4600.2)
==1942==  If you believe this happened as a result of a stack
==1942==  overflow in your program's main thread (unlikely but
==1942==  possible), you can try to increase the size of the
==1942==  main thread stack using the --main-stacksize= flag.
==1942==  The main thread stack size used in this run was 8388608.
==1942== 
==1942== HEAP SUMMARY:
==1942==     in use at exit: 19,785,402 bytes in 241,145 blocks
==1942==   total heap usage: 4,056,401 allocs, 3,815,256 frees, 248,289,100 bytes allocated
==1942== 
==1942== LEAK SUMMARY:
==1942==    definitely lost: 108 bytes in 2 blocks
==1942==    indirectly lost: 3,276 bytes in 67 blocks
==1942==      possibly lost: 761,773 bytes in 3,401 blocks
==1942==    still reachable: 19,020,245 bytes in 237,675 blocks
==1942==         suppressed: 0 bytes in 0 blocks
==1942== Rerun with --leak-check=full to see details of leaked memory
==1942== 
==1942== For counts of detected and suppressed errors, rerun with: -v
==1942== Use --track-origins=yes to see where uninitialised values come from
==1942== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Comment 4 Christoph Feck 2016-06-12 12:55:30 UTC
Thanks, this is indeed kmix. After gdb shows you that the application crashed, you need to use the "bt" command in gdb to view the backtrace. Please add this output.
Comment 5 Uģis 2016-06-12 13:19:24 UTC
Created attachment 99471 [details]
gdb bt

gdb backtrace
Comment 6 Christoph Feck 2016-06-12 13:25:46 UTC
Thanks, it is an endless recursion, that's why the KDE crash dialog cannot work.
Backtrace from comment #5:

Thread 1 (Thread 0x7fffe4bf1840 (LWP 2200)):
#0  0x00007fffefe0abbb in g_main_context_wakeup () from /usr/lib/libglib-2.0.so.0
#1  0x00007ffff3e061aa in QCoreApplication::postEvent(QObject*, QEvent*, int) () from /usr/lib/libQt5Core.so.5
#2  0x00007ffff3e2f835 in QMetaObject::activate(QObject*, int, int, void**) () from /usr/lib/libQt5Core.so.5
#3  0x00007ffff7f579bf in ?? () from /usr/lib/libQt5DBus.so.5
#4  0x00007ffff7f05643 in ?? () from /usr/lib/libQt5DBus.so.5
#5  0x00007ffff7efde1d in QDBusConnection::send(QDBusMessage const&) const () from /usr/lib/libQt5DBus.so.5
#6  0x00007ffff7b3fed7 in DBusMixerWrapper::refreshVolumeLevels (this=0x8f45c0) at /chakra/desktop/kmix/src/kmix-16.04.1/dbus/dbusmixerwrapper.cpp:135
        signal = {d_ptr = 0x16f3720}
#7  0x00007ffff7b4008d in DBusMixerWrapper::controlsChange (this=<optimized out>, changeType=<optimized out>)
    at /chakra/desktop/kmix/src/kmix-16.04.1/dbus/dbusmixerwrapper.cpp:69
#8  0x00007ffff7bb0e3b in DBusMixerWrapper::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>)
    at /chakra/desktop/kmix/src/build/moc_dbusmixerwrapper.cpp:91
        _t = <optimized out>
#9  0x00007ffff3e0e60a in QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const () from /usr/lib/libQt5Core.so.5
#10 0x00007ffff3e14001 in QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) ()
   from /usr/lib/libQt5Core.so.5
#11 0x00007ffff7b9dc02 in QMetaObject::invokeMethod (val9=..., val8=..., val7=..., val6=..., val5=..., val4=..., val3=..., val2=..., val1=..., val0=..., 
    type=Qt::DirectConnection, member=0x7ffff7bbbbb6 "controlsChange", obj=<optimized out>) at /usr/include/qt5/QtCore/qobjectdefs.h:413
#12 ControlManager::announce (this=0x7ffff7ddad10 <ControlManager::instanceSingleton>, mixerId=..., changeType=changeType@entry=ControlChangeType::TypeFirst, 
    sourceId=...) at /chakra/desktop/kmix/src/kmix-16.04.1/core/ControlManager.cpp:79
        mixerIsOfInterest = true
        it = {i = 0x955bf8}
        listenersModified = false
        processedListeners = {q_hash = {{d = 0x7ffff3ed1380 <QHashData::shared_null>, e = 0x7ffff3ed1380 <QHashData::shared_null>}}}
        __PRETTY_FUNCTION__ = "void ControlManager::announce(QString, ControlChangeType::Type, QString)"
#13 0x00007ffff7ba3d57 in Mixer::commitVolumeChange (this=<optimized out>, md=std::shared_ptr (count 8, weak 0) 0x8d0c90)
    at /chakra/desktop/kmix/src/kmix-16.04.1/core/mixer.cpp:666
        __PRETTY_FUNCTION__ = "void Mixer::commitVolumeChange(std::shared_ptr<MixDevice>)"
#14 0x00007ffff7b7f881 in MDWSlider::increaseOrDecreaseVolume (this=this@entry=0x8bd680, decrease=decrease@entry=true, 
    volumeType=volumeType@entry=Volume::Playback) at /chakra/desktop/kmix/src/kmix-16.04.1/gui/mdwslider.cpp:1035
#15 0x00007ffff7b859a9 in MDWSlider::eventFilter (this=0x8bd680, obj=<optimized out>, e=<optimized out>)
    at /chakra/desktop/kmix/src/kmix-16.04.1/gui/mdwslider.cpp:1304
        qwe = <optimized out>
        increase = <optimized out>
        volumeType = Volume::Playback
        slider = 0x899590
#16 0x00007ffff3e03402 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#17 0x00007ffff4738085 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#18 0x00007ffff473f246 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#19 0x00007ffff3e03698 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#20 0x00007ffff477d858 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
#21 0x00007ffff47380ac in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#22 0x00007ffff473f246 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5
#23 0x00007ffff3e03698 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5
#24 0x00007ffff477d858 in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5
[...]
Comment 7 xunilhcra 2016-07-01 15:30:59 UTC
Same issue here.

openSUSE Tumbleweed
Plasma 5.6.4
Frameworks: 5.22.0
Qt 5.6.1

I would be happy to drop kmix if plasma-pa provided per-application volume streams, but it doesn't unless you right mouse click on the tray icon and go to "Adjust Volume Settings". Verticle sliders also should be an option. So for now I'm stuck with kmix.
Comment 8 Rex Dieter 2016-07-01 16:29:29 UTC
plasma-pa since 5.6 does provide per-application streams (in audio settings).  in 5.7 they're available in a (more accessible) tab next to devices.
Comment 9 Uģis 2016-07-01 16:38:13 UTC
I use 5.7 beta now, and plasma-pa is almost on par with kmix. It even has volume overdrive now
I don't use kmix now anymore
Comment 10 Alexander Zaika 2016-07-11 04:35:52 UTC
I have same issue, looks like kmix have infinity recursion on QWheelEvent:

#31 0x00007f2b5d5128c8 in QWidget::event (this=0x282ac80, event=0x7ffe0ea17730) at kernel/qwidget.cpp:8971
#32 0x00007f2b5d4c51f4 in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x282ac80, e=0x7ffe0ea17730) at kernel/qapplication.cpp:3804
#33 0x00007f2b5d4cb80b in QApplication::notify (this=<optimized out>, receiver=0x282a0e0, e=0x7ffe0ea17b60) at kernel/qapplication.cpp:3369
#34 0x00007f2b5cbb0170 in QCoreApplication::notifyInternal2 (receiver=0x282a0e0, event=0x7ffe0ea17b60) at kernel/qcoreapplication.cpp:1015
#35 0x00007f2b5d5128c8 in QWidget::event (this=0x282ac80, event=0x7ffe0ea17b60) at kernel/qwidget.cpp:8971

And this repeat until stack overflow (about 32K frames on my PC).

I have modify kmix-16.04.2/gui/viewdockareapopup.cpp:
void ViewDockAreaPopup::wheelEvent ( QWheelEvent * e )
{
  if ( _mdws.isEmpty() )
    return;

   // Pass wheel event from "border widget" to child
//   QApplication::sendEvent( _mdws.first(), e); - recursion here
}

And now kmix work fine for me now.

As I understand - QApplication::sendEvent( _mdws.first(), e); must send event to slider widget from the parent widget, but looks like slider not have a focus so system transmit wheel event again to parent (self) as result we fail to infinity recursion. Simple remove this code require user hover slider for use wheel.
Comment 11 coffnix 2016-08-02 13:03:54 UTC
Same problem here in Funtoo (Gentoo based).

Plasma-pa not work on alsa only. Pulseaudio is sux. Kmix is essential to Alsa.
Comment 12 Azamat H. Hackimov 2016-08-03 17:23:30 UTC
Created attachment 100436 [details]
Fix-for-crashing-on-mousewheel-event-bug-364141.patch

Proposed patch from Fedora packaging (http://pkgs.fedoraproject.org/cgit/rpms/kmix.git/commit/?id=3c680dd8ef185d2bd4aca22f69a517a988a01d0c)
Comment 13 Andreas Sturmlechner 2016-08-03 19:53:57 UTC
Git commit 7aa904ecacfd2eeaa91068e17cc9bd79ba058206 by Andreas Sturmlechner.
Committed on 28/07/2016 at 21:27.
Pushed by asturmlechner into branch 'Applications/16.08'.

Fix infinite recursion by scroll wheel volume change
REVIEW: 128546

M  +3    -1    gui/viewdockareapopup.cpp

http://commits.kde.org/kmix/7aa904ecacfd2eeaa91068e17cc9bd79ba058206
Comment 14 coffnix 2016-08-03 22:39:05 UTC
Fixed with patches kmix-15.08.2-autostart_disable.patch and kmix-kdebug364141.patch here on Funtoo Linux. Thanks :D