Bug 212944

Summary: Increasing/decreasing volume using multimedia keys crashes KMix when using OSS [[MixDevice::isMuted], Mixer_OSS::writeVolumeToHW, KMixWindow::increaseOrDecreaseVolume]
Product: [Applications] kmix Reporter: Adam Kovari <kovariadam>
Component: generalAssignee: Christian Esken <esken>
Status: RESOLVED FIXED    
Severity: crash CC: andresbajotierra, edward.hades, lme, toma
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: patch that fixes the oss crash
patch that fixes the oss crash
New crash information added by DrKonqi

Description Adam Kovari 2009-11-03 18:39:40 UTC
Application that crashed: kmix
Version of the application: 3.5
KDE Version: 4.3.3 (KDE 4.3.3)
Qt Version: 4.5.3
Operating System: Linux 2.6.31-ARCH x86_64

What I was doing when the application crashed:
this happens since i switched from alsa to OSS

 -- Backtrace:
Application: KMix (kmix), signal: Segmentation fault
[KCrash Handler]
#5  MixDevice::isMuted (this=0x16ec280, id=<value optimized out>, md=0x0) at /home/phil/kdemod/core/kdemultimedia/src/kdemultimedia-4.3.3/kmix/mixdevice.h:130
#6  Mixer_OSS::writeVolumeToHW (this=0x16ec280, id=<value optimized out>, md=0x0) at /home/phil/kdemod/core/kdemultimedia/src/kdemultimedia-4.3.3/kmix/mixer_oss.cpp:376
#7  0x00007f0197203ee9 in KMixWindow::increaseOrDecreaseVolume (this=0x1579250, increase=<value optimized out>) at /home/phil/kdemod/core/kdemultimedia/src/kdemultimedia-4.3.3/kmix/kmix.cpp:624
#8  0x00007f0197206c6c in KMixWindow::qt_metacall (this=0x1579250, _c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0x7fffb1988eb0)
    at /home/phil/kdemod/core/kdemultimedia/src/kdemultimedia-4.3.3/kmix/kmix.moc:109
#9  0x00007f019527c47c in QMetaObject::activate (sender=0x165d4d0, from_signal_index=<value optimized out>, to_signal_index=<value optimized out>, argv=0x80000004) at kernel/qobject.cpp:3112
#10 0x00007f01944f27b7 in QAction::triggered (this=0x0, _t1=false) at .moc/release-shared/moc_qaction.cpp:236
#11 0x00007f01944f3bff in QAction::activate (this=0x165d4d0, event=<value optimized out>) at kernel/qaction.cpp:1167
#12 0x00007f01963e6cf4 in KGlobalAccelPrivate::_k_invokeAction(QStringList const&, long long) () from /usr/lib/libkdeui.so.5
#13 0x00007f01963eb0b4 in KGlobalAccel::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5
#14 0x00007f019527c47c in QMetaObject::activate (sender=0x165d188, from_signal_index=<value optimized out>, to_signal_index=<value optimized out>, argv=0x80000004) at kernel/qobject.cpp:3112
#15 0x00007f01964ea9c4 in OrgKdeKGlobalAccelInterface::invokeAction(QStringList const&, long long) () from /usr/lib/libkdeui.so.5
#16 0x00007f01964eacf3 in OrgKdeKGlobalAccelInterface::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5
#17 0x00007f019557d934 in QDBusConnectionPrivate::deliverCall (this=<value optimized out>, object=<value optimized out>, msg=<value optimized out>, metaTypes=..., slotIdx=<value optimized out>)
    at qdbusintegrator.cpp:891
#18 0x00007f0195584c3f in QDBusCallDeliveryEvent::placeMetaCall(QObject*) () from /usr/lib/libQtDBus.so.4
#19 0x00007f0195276799 in QObject::event (this=0x165d188, e=0x176d6b0) at kernel/qobject.cpp:1110
#20 0x00007f01944f860c in QApplicationPrivate::notify_helper (this=0x1588340, receiver=0x165d188, e=0x176d6b0) at kernel/qapplication.cpp:4065
#21 0x00007f01944ff8de in QApplication::notify (this=0x15723f0, receiver=0x165d188, e=0x176d6b0) at kernel/qapplication.cpp:4030
#22 0x00007f01963a3926 in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#23 0x00007f019526733c in QCoreApplication::notifyInternal (this=0x15723f0, receiver=0x165d188, event=0x176d6b0) at kernel/qcoreapplication.cpp:610
#24 0x00007f0195267f4a in QCoreApplication::sendEvent (receiver=0x0, event_type=<value optimized out>, data=0x1533b60) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:213
#25 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=<value optimized out>, data=0x1533b60) at kernel/qcoreapplication.cpp:1247
#26 0x00007f019528fcc3 in QCoreApplication::sendPostedEvents (s=<value optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:218
#27 postEventSourceDispatch (s=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:276
#28 0x00007f01917ed1fe in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#29 0x00007f01917f0bb8 in g_main_context_iterate () from /usr/lib/libglib-2.0.so.0
#30 0x00007f01917f0ce0 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#31 0x00007f019528f863 in QEventDispatcherGlib::processEvents (this=0x1588690, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:407
#32 0x00007f019458b6de in QGuiEventDispatcherGlib::processEvents (this=0x0, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:202
#33 0x00007f0195265c72 in QEventLoop::processEvents (this=<value optimized out>, flags=) at kernel/qeventloop.cpp:149
#34 0x00007f0195266044 in QEventLoop::exec (this=0x7fffb198a120, flags=) at kernel/qeventloop.cpp:201
#35 0x00007f01952681f9 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:888
#36 0x00007f0197203932 in kdemain (argc=<value optimized out>, argv=<value optimized out>) at /home/phil/kdemod/core/kdemultimedia/src/kdemultimedia-4.3.3/kmix/main.cpp:71
#37 0x00007f0196eb29ed in __libc_start_main () from /lib/libc.so.6
#38 0x0000000000400629 in _start ()

Reported using DrKonqi
Comment 1 Dario Andres 2009-11-10 00:50:46 UTC
*** Bug 213601 has been marked as a duplicate of this bug. ***
Comment 2 Dario Andres 2009-11-10 00:50:49 UTC
*** Bug 213670 has been marked as a duplicate of this bug. ***
Comment 3 Dario Andres 2010-02-17 20:13:30 UTC
From bug 227421:
-- Information about the crash:
"Decrease volume" multimedia key cases crash, using OSSv4
happens all the time, but scrolling on the tray icon works well.
The crash can be reproduced every time.
Comment 4 Dario Andres 2010-02-17 20:13:41 UTC
*** Bug 227421 has been marked as a duplicate of this bug. ***
Comment 5 Christian Esken 2010-05-19 12:14:20 UTC
SVN commit 1128461 by esken:

Backport a fix to 4.3 for a possible crash on shwowing the Volume OSD.
CCBUGS: 212944


 M  +3 -0      kmix.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1128461
Comment 6 Christian Esken 2010-05-19 12:21:53 UTC
Fixed in KDE4.4.1, the future KDE4.5, and in the KDE4.3 branch (for a possible vendor service release).

Problems were suboptimal Master selection, and non-guarded null-pointers. With the patches it won't crash even when there is no master at all.
Comment 7 Christian Esken 2010-05-19 17:31:05 UTC
*** Bug 205621 has been marked as a duplicate of this bug. ***
Comment 8 Edward Hades 2010-06-15 21:16:41 UTC
Somehow this still happens in KDE 4.4.4.

Let me debug it a bit...
Comment 9 Edward Hades 2010-06-15 21:57:51 UTC
Here's the backtrace:

Program received signal SIGSEGV, Segmentation fault.
0xb789ba81 in Volume::getVolume (this=0xc, chid=Volume::CHIDMIN) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/volume.cpp:178
178         if ( (chmask & _chmask) != 0 ) {
(gdb) bt
#0  0xb789ba81 in Volume::getVolume (this=0xc, chid=Volume::CHIDMIN) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/volume.cpp:178
#1  0xb788ebcb in Mixer_OSS4::writeVolumeToHW (this=0x92992a0, id=..., md=0x0) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/mixer_oss4.cpp:637
#2  0xb788c48f in Mixer::decreaseVolume (this=0x9279678, mixdeviceID=...) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/mixer.cpp:625
#3  0xb787657a in KMixWindow::increaseOrDecreaseVolume (this=0x91602c0, increase=false) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/kmix.cpp:624
#4  0xb78765c9 in KMixWindow::slotDecreaseVolume (this=0x91602c0) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/kmix.cpp:636
#5  0xb78780dd in KMixWindow::qt_metacall (this=0x91602c0, _c=QMetaObject::InvokeMetaMethod, _id=19, _a=0xbf89204c)
    at /home/hades/dev/kmix/kdemultimedia-4.4.4/build/kmix/kmix.moc:123
#6  0xb6d551df in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/qt4/libQtCore.so.4
#7  0xb6d6318b in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/qt4/libQtCore.so.4
#8  0xb6305df4 in QAction::triggered(bool) () from /usr/lib/qt4/libQtGui.so.4
#9  0xb6307e23 in QAction::activate(QAction::ActionEvent) () from /usr/lib/qt4/libQtGui.so.4
#10 0xb7331622 in KGlobalAccelPrivate::_k_invokeAction(QStringList const&, long long) () from /usr/lib/libkdeui.so.5
#11 0xb7336337 in KGlobalAccel::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5
#12 0xb6d551df in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/qt4/libQtCore.so.4
#13 0xb6d6318b in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/qt4/libQtCore.so.4
#14 0xb74412f0 in OrgKdeKGlobalAccelInterface::invokeAction(QStringList const&, long long) () from /usr/lib/libkdeui.so.5
#15 0xb74422c5 in OrgKdeKGlobalAccelInterface::qt_metacall(QMetaObject::Call, int, void**) () from /usr/lib/libkdeui.so.5
#16 0xb6e80eb6 in QDBusConnectionPrivate::deliverCall(QObject*, int, QDBusMessage const&, QList<int> const&, int) () from /usr/lib/qt4/libQtDBus.so.4
#17 0xb6e8b391 in QDBusCallDeliveryEvent::placeMetaCall(QObject*) () from /usr/lib/qt4/libQtDBus.so.4
#18 0xb6d60214 in QObject::event(QEvent*) () from /usr/lib/qt4/libQtCore.so.4
#19 0xb630bf2d in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/qt4/libQtGui.so.4
#20 0xb6312e9d in QApplication::notify(QObject*, QEvent*) () from /usr/lib/qt4/libQtGui.so.4
#21 0xb72da82e in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#22 0xb6d503f5 in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/qt4/libQtCore.so.4
#23 0xb6d51243 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/qt4/libQtCore.so.4
#24 0xb6d513e2 in QCoreApplication::sendPostedEvents(QObject*, int) () from /usr/lib/qt4/libQtCore.so.4
#25 0xb6d79e3e in postEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /usr/lib/qt4/libQtCore.so.4
#26 0xb5fe798e in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
#27 0xb5fead61 in g_main_context_iterate () from /usr/lib/libglib-2.0.so.0
#28 0xb5feaec2 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
#29 0xb6d799ce in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#30 0xb63be2be in QGuiEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtGui.so.4
#31 0xb6d4ec8f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#32 0xb6d4f095 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
#33 0xb6d5148f in QCoreApplication::exec() () from /usr/lib/qt4/libQtCore.so.4
#34 0xb630bfc2 in QApplication::exec() () from /usr/lib/qt4/libQtGui.so.4
#35 0xb7875c92 in kdemain (argc=1, argv=0xbf893034) at /home/hades/dev/kmix/kdemultimedia-4.4.4/kmix/main.cpp:71
#36 0x08048712 in main (argc=Cannot access memory at address 0xc
) at /home/hades/dev/kmix/kdemultimedia-4.4.4/build/kmix/kmix_dummy.cpp:3

The md is null in Mixer::decreaseVolume( const QString& ):

mixer.cpp:625    _mixerBackend->writeVolumeToHW(mixdeviceID, md);
Comment 10 Edward Hades 2010-06-15 22:51:56 UTC
Created attachment 48043 [details]
patch that fixes the oss crash
Comment 11 Edward Hades 2010-06-15 22:53:22 UTC
Created attachment 48044 [details]
patch that fixes the oss crash

Sorry, swapped sides accidentally.
Comment 12 Christian Esken 2010-08-21 15:03:21 UTC
The observation is correct:  ID is actually an index in the Mixer::_mixerBackend->m_mixDevices array. Or it should  be so at least, as Edward found out it doesn't work:
The core reason for the bug is that the OSSv4 backend neglects to implement/ overload the id2num() method.

While the patch is working, I can't apply it. It makes all backends more inefficient (because a "full scan" is done on each call). Correct would be to implement the  id2num() method in the OSSv4 backend.

I personally can't support OSSv4 (due to lack of driver), but surely I am still interested in a patch. If you could do it (or Maxime, who did the KDE4 port)., I'll integrate it. As a starting point you can look at Mixer_PULSE::id2num() or Mixer_ALSA::id2num(). First uses a search loop, the latter a hashmap.
Comment 13 Lars Engels 2010-09-08 13:37:37 UTC
Created attachment 51422 [details]
New crash information added by DrKonqi

Same here on PCBSD 8.1 with KDE 4.4.5.
As a side note: Rasing volume shows an empty Volume OSD.
Comment 14 Edward Hades 2010-09-09 12:22:14 UTC
Then the id2num in parent class Mixer_Backend is incorrect, because it does not implement sufficiently generic behavior.
Comment 15 Lars Engels 2010-09-17 09:31:56 UTC
Update: The crash only occurs when the "wrong" main channel is selected.
It was set to "monitor" here. Now I changed it to PCM and it's working again.
Comment 16 Christian Esken 2011-08-22 22:23:29 UTC
I re-read the comments of this bug report. Something went wrong here. The original bug report is about OSS(3). Actually its a generic issue and it is resolved. The latest comments - starting with comment 9 - are about OSS4.

In any case it looks I did not detect the following line until today:
0xb788ebcb in Mixer_OSS4::writeVolumeToHW (this=0x92992a0, id=..., md=0x0)

Ouch. md=0x0 means, I produced a NPE. Probably I found it now, as I applied a fix for this today. The KDE4.7 branch has been patched, and also Trunk.
Comment 17 Christian Esken 2011-08-22 22:28:47 UTC
SVN commit 1248941 by esken:

BUGS: 245383
BUGS: 212944
Fix NPE when decreasing volume. Forward port to trunk.

 M  +14 -27    mixer.cpp  
 M  +1 -1      mixer.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1248941