Bug 234781 - javascript plasmoid + python dataengine: Too many open files
Summary: javascript plasmoid + python dataengine: Too many open files
Status: RESOLVED FIXED
Alias: None
Product: plasma4
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-19 10:20 UTC by Nikita Melnichenko
Modified: 2010-06-05 00:01 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
plasmoid that's crashed (1.84 KB, application/x-bzip2)
2010-04-19 11:01 UTC, Nikita Melnichenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Melnichenko 2010-04-19 10:20:00 UTC
Application: plasmoidviewer (1.0)
KDE Platform Version: 4.4.2 (KDE 4.4.2) (Compiled from sources)
Qt Version: 4.6.2
Operating System: Linux 2.6.33.1-c2 x86_64
Distribution (Platform): Gentoo Packages

-- Information about the crash:
My Make Progress! plasmoid crashes (and crash Plasma, of course) when it have many live items or they're frequently updated. I investigated this bug and created a small plasmoid that has the same crash. That should ease debugging.

Futher information and sample plasmoid would be in comments.

The crash can be reproduced every time.

 -- Backtrace:
Application: Просмотр виджета Plasma (plasmoidviewer), signal: Bus error
The current source language is "auto; currently c".
[Current thread is 1 (Thread 0x7f9021bab790 (LWP 7651))]

Thread 2 (Thread 0x7f9008a1b910 (LWP 7652)):
#0  pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:261
#1  0x00007f9008b4421a in QTWTF::TCMalloc_PageHeap::scavengerThread (this=0x7f9008e1c200) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:2304
#2  0x00007f9008b4424f in QTWTF::TCMalloc_PageHeap::runScavengerThread (context=0x7f9008e2a2cc) at ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastMalloc.cpp:1438
#3  0x00007f902028d2a7 in start_thread (arg=<value optimized out>) at pthread_create.c:297
#4  0x00007f901ea008cd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5  0x0000000000000000 in ?? ()

Thread 1 (Thread 0x7f9021bab790 (LWP 7651)):
[KCrash Handler]
#5  0x00007f90205d67a1 in QProcessPrivate::waitForStarted (this=0x320a790, msecs=30000) at io/qprocess_unix.cpp:912
#6  0x00007f902059be63 in QProcess::waitForStarted (this=0x3209b70, msecs=30000) at io/qprocess.cpp:1611
#7  0x00007f901c6cabcc in KProcessRunner (this=0x3209010, p=0x3209b70, executable=..., _id=...) at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kio/kio/krun.cpp:1649
#8  0x00007f901c6cac3c in KProcessRunner::run (p=0x3209b70, executable=..., id=...) at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kio/kio/krun.cpp:1631
#9  0x00007f901c6cb84b in runCommandInternal (proc=0x3209b70, service=0x3207010, executable=..., userVisibleName=..., iconName=..., window=0x0, asn=...)
    at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kio/kio/krun.cpp:572
#10 0x00007f901c6cbda1 in KRun::runCommand (cmd=..., execName=..., iconName=..., window=0x0, asn=..., workingDirectory=...)
    at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kio/kio/krun.cpp:1046
#11 0x00007f901c6cbfb1 in KRun::runCommand (cmd=..., window=0x0, workingDirectory=...) at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kio/kio/krun.cpp:1020
#12 0x00007f901c6cc170 in KRun::runCommand (cmd=..., window=0x7530) at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kio/kio/krun.cpp:1010
#13 0x00007f9008e47d9a in SimpleJavaScriptApplet::runCommand (context=0x7fff8af4fcf0, engine=<value optimized out>)
    at /var/tmp/portage/kde-base/plasma-runtime-4.4.2/work/plasma-runtime-4.4.2/plasma/scriptengines/javascript/simplejavascriptapplet.cpp:388
#14 0x00007f9008b7f3e2 in QScript::FunctionWrapper::proxyCall (exec=<value optimized out>, callee=0x7f9007c90b00, thisObject=<value optimized out>, args=<value optimized out>)
    at bridge/qscriptfunction.cpp:82
#15 0x00007f9008ac61f2 in QTJSC::NativeFuncWrapper::operator() (this=0x7fff8af50240, exec=0x7f9007d030a8, jsobj=0x7f9007c90b00, thisValue=..., argList=...)
    at ../3rdparty/javascriptcore/JavaScriptCore/runtime/CallData.cpp:46
#16 0x00007f9008ab4c8a in QTJSC::Interpreter::privateExecute (this=0x7f9008124b00, flag=<value optimized out>, registerFile=0x7f9008124b10, callFrame=0x7f9007d03048, exception=0x7f90081199b8)
    at ../3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp:3103
#17 0x00007f9008ab6569 in QTJSC::Interpreter::execute (this=0x7f9008124b00, functionExecutable=0x7f900816ba50, callFrame=0x1a73c48, function=0x7f9007c90d80, thisObj=<value optimized out>, args=..., 
    scopeChain=0x7f900811f4b0, exception=0x7f90081199b8) at ../3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.cpp:753
#18 0x00007f9008aef9d8 in QTJSC::JSFunction::call (this=0x7f9007c90d80, exec=0x1a73c48, thisValue=..., args=...) at ../3rdparty/javascriptcore/JavaScriptCore/runtime/JSFunction.cpp:120
#19 0x00007f9008ac621c in QTJSC::call (exec=<value optimized out>, functionObject=..., callType=<value optimized out>, callData=..., thisValue=..., args=...)
    at ../3rdparty/javascriptcore/JavaScriptCore/runtime/CallData.cpp:62
#20 0x00007f9008b896a0 in QScript::QObjectConnectionManager::execute (this=0x239ea50, slotIndex=<value optimized out>, argv=<value optimized out>) at bridge/qscriptqobject.cpp:2220
#21 0x00007f9008b899f3 in QScript::QObjectConnectionManager::qt_metacall (this=0x239ea50, _c=QMetaObject::InvokeMetaMethod, _id=63, _a=0x7fff8af50df0) at bridge/qscriptqobject.cpp:2127
#22 0x00007f90206099f0 in QMetaObject::activate (sender=0x1a483e0, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3285
#23 0x00007f90211c00a2 in Plasma::PushButton::qt_metacall (this=0x1a483e0, _c=QMetaObject::InvokeMetaMethod, _id=<value optimized out>, _a=0x7fff8af50f90)
    at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2_build/plasma/pushbutton.moc:101
#24 0x00007f90206099f0 in QMetaObject::activate (sender=0x1ab2bd0, m=<value optimized out>, local_signal_index=<value optimized out>, argv=0x0) at kernel/qobject.cpp:3285
#25 0x00007f901fbe1b60 in QAbstractButton::clicked (this=0x7fff8af4f8b0, _t1=false) at .moc/release-shared/moc_qabstractbutton.cpp:206
#26 0x00007f901f93e2b8 in QAbstractButtonPrivate::emitClicked (this=0x1ef7710) at widgets/qabstractbutton.cpp:546
#27 0x00007f901f93ef5a in QAbstractButtonPrivate::click (this=0x1ef7710) at widgets/qabstractbutton.cpp:539
#28 0x00007f901f93f14c in QAbstractButton::mouseReleaseEvent (this=0x1ab2bd0, e=0x3204f10) at widgets/qabstractbutton.cpp:1121
#29 0x00007f901f629e38 in QWidget::event (this=0x1ab2bd0, event=0x3204f10) at kernel/qwidget.cpp:7998
#30 0x00007f901f5dc3d6 in QApplicationPrivate::notify_helper (this=0x18ded60, receiver=0x1ab2bd0, e=0x3204f10) at kernel/qapplication.cpp:4300
#31 0x00007f901f5e3b3d in QApplication::notify (this=<value optimized out>, receiver=0x1ab2bd0, e=0x3204f10) at kernel/qapplication.cpp:3865
#32 0x00007f90216de754 in KApplication::notify (this=0x7fff8af53ca0, receiver=0x1ab2bd0, event=0x3204f10)
    at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kdeui/kernel/kapplication.cpp:302
#33 0x00007f90205f82f4 in QCoreApplication::notifyInternal (this=0x7fff8af53ca0, receiver=0x1ab2bd0, event=0x3204f10) at kernel/qcoreapplication.cpp:704
#34 0x00007f901f5e1d3b in QCoreApplication::sendEvent (receiver=0x1ab2bd0, event=0x3204f10, alienWidget=0x0, nativeWidget=0x1ab2bd0, buttonDown=0x7fff8af519a8, lastMouseReceiver=..., spontaneous=
    true) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#35 QApplicationPrivate::sendMouseEvent (receiver=0x1ab2bd0, event=0x3204f10, alienWidget=0x0, nativeWidget=0x1ab2bd0, buttonDown=0x7fff8af519a8, lastMouseReceiver=..., spontaneous=true)
    at kernel/qapplication.cpp:2965
#36 0x00007f901fb5da4d in QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent (this=0x1ef7200, event=0x7fff8af52330) at graphicsview/qgraphicsproxywidget.cpp:283
#37 0x00007f901fb4dbf9 in QGraphicsItem::sceneEvent (this=0x1a483f0, event=0x7530) at graphicsview/qgraphicsitem.cpp:6499
#38 0x00007f901fb61674 in QGraphicsScenePrivate::sendMouseEvent (this=0x19e0f90, mouseEvent=0x7fff8af52330) at graphicsview/qgraphicsscene.cpp:1255
#39 0x00007f901fb65394 in QGraphicsScene::mouseReleaseEvent (this=<value optimized out>, mouseEvent=0x7fff8af52330) at graphicsview/qgraphicsscene.cpp:4057
#40 0x00007f901fb74e81 in QGraphicsScene::event (this=0x7fff8af53b48, event=0x7fff8af52330) at graphicsview/qgraphicsscene.cpp:3398
#41 0x00007f901f5dc3d6 in QApplicationPrivate::notify_helper (this=0x18ded60, receiver=0x7fff8af53b48, e=0x7fff8af52330) at kernel/qapplication.cpp:4300
#42 0x00007f901f5e2e74 in QApplication::notify (this=0x7fff8af53ca0, receiver=0x7fff8af53b48, e=0x7fff8af52330) at kernel/qapplication.cpp:3704
#43 0x00007f90216de754 in KApplication::notify (this=0x7fff8af53ca0, receiver=0x7fff8af53b48, event=0x7fff8af52330)
    at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kdeui/kernel/kapplication.cpp:302
#44 0x00007f90205f82f4 in QCoreApplication::notifyInternal (this=0x7fff8af53ca0, receiver=0x7fff8af53b48, event=0x7fff8af52330) at kernel/qcoreapplication.cpp:704
#45 0x00007f901fb8d6bc in QGraphicsView::mouseReleaseEvent (this=0x7fff8af53b20, event=0x7fff8af52f80) at graphicsview/qgraphicsview.cpp:3259
#46 0x00007f901f629e38 in QWidget::event (this=0x7fff8af53b20, event=0x7fff8af52f80) at kernel/qwidget.cpp:7998
#47 0x00007f901f97edc6 in QFrame::event (this=0x7fff8af53b20, e=0x7fff8af52f80) at widgets/qframe.cpp:557
#48 0x00007f901fb8af29 in QGraphicsView::viewportEvent (this=0x7fff8af53b20, event=0x7fff8af52f80) at graphicsview/qgraphicsview.cpp:2787
#49 0x00007f90205f793a in QCoreApplicationPrivate::sendThroughObjectEventFilters (this=<value optimized out>, receiver=0x19e0560, event=0x7fff8af52f80) at kernel/qcoreapplication.cpp:819
#50 0x00007f901f5dc3b5 in QApplicationPrivate::notify_helper (this=0x18ded60, receiver=0x19e0560, e=0x7fff8af52f80) at kernel/qapplication.cpp:4296
#51 0x00007f901f5e3b3d in QApplication::notify (this=<value optimized out>, receiver=0x19e0560, e=0x7fff8af52f80) at kernel/qapplication.cpp:3865
#52 0x00007f90216de754 in KApplication::notify (this=0x7fff8af53ca0, receiver=0x19e0560, event=0x7fff8af52f80)
    at /var/tmp/portage/kde-base/kdelibs-4.4.2/work/kdelibs-4.4.2/kdeui/kernel/kapplication.cpp:302
#53 0x00007f90205f82f4 in QCoreApplication::notifyInternal (this=0x7fff8af53ca0, receiver=0x19e0560, event=0x7fff8af52f80) at kernel/qcoreapplication.cpp:704
#54 0x00007f901f5e1d3b in QCoreApplication::sendEvent (receiver=0x19e0560, event=0x7fff8af52f80, alienWidget=0x19e0560, nativeWidget=0x7fff8af53b20, buttonDown=0x7f902002a9e8, lastMouseReceiver=..., 
    spontaneous=true) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:215
#55 QApplicationPrivate::sendMouseEvent (receiver=0x19e0560, event=0x7fff8af52f80, alienWidget=0x19e0560, nativeWidget=0x7fff8af53b20, buttonDown=0x7f902002a9e8, lastMouseReceiver=..., spontaneous=
    true) at kernel/qapplication.cpp:2965
#56 0x00007f901f6587ed in QETWidget::translateMouseEvent (this=0x7fff8af53b20, event=<value optimized out>) at kernel/qapplication_x11.cpp:4368
#57 0x00007f901f657745 in QApplication::x11ProcessEvent (this=0x7fff8af53ca0, event=0x7fff8af53760) at kernel/qapplication_x11.cpp:3501
#58 0x00007f901f67d78a in x11EventSourceDispatch (s=0x18e29f0, callback=0, user_data=0x0) at kernel/qguieventdispatcher_glib.cpp:146
#59 0x00007f9018d7b073 in g_main_dispatch (context=0x18e1920) at gmain.c:1960
#60 IA__g_main_context_dispatch (context=0x18e1920) at gmain.c:2513
#61 0x00007f9018d7e16c in g_main_context_iterate (context=0x18e1920, block=1, dispatch=1, self=<value optimized out>) at gmain.c:2591
#62 0x00007f9018d7e2ee in IA__g_main_context_iteration (context=0x18e1920, may_block=1) at gmain.c:2654
#63 0x00007f902061dc74 in QEventDispatcherGlib::processEvents (this=0x18c53d0, flags=<value optimized out>) at kernel/qeventdispatcher_glib.cpp:412
#64 0x00007f901f67d3a6 in QGuiEventDispatcherGlib::processEvents (this=0x7fff8af4f8b0, flags=<value optimized out>) at kernel/qguieventdispatcher_glib.cpp:204
#65 0x00007f90205f6fb4 in QEventLoop::processEvents (this=<value optimized out>, flags=...) at kernel/qeventloop.cpp:149
#66 0x00007f90205f72ff in QEventLoop::exec (this=0x7fff8af53a90, flags=...) at kernel/qeventloop.cpp:201
#67 0x00007f90205f92de in QCoreApplication::exec () at kernel/qcoreapplication.cpp:981
#68 0x000000000040aa2d in main (argc=2, argv=0x7fff8af54598) at /var/tmp/portage/kde-base/plasma-workspace-4.4.2/work/plasma-workspace-4.4.2/plasma/generic/shells/plasmoidviewer/main.cpp:231
The current source language is "auto; currently asm".
The current source language is "auto; currently c".

Reported using DrKonqi
Comment 1 Nikita Melnichenko 2010-04-19 11:01:51 UTC
Created attachment 42889 [details]
plasmoid that's crashed

The Make Progress data engine should be installed:
http://nikita.melnichenko.name/download.php?q=make-progress-0.1.0.engine

Steps to reprodice:
1. run in plasmoidviewer
You will see many strings in console like that:
plasmoidviewer(14515)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
They will be mixed with replies from engine.
2. click the button, notification should appear
3. wait until replies stop printing (there would be only writeConfig lines)
4. click again -> crash
Comment 2 Nikita Melnichenko 2010-04-19 11:20:38 UTC
There are also these messages in console before crash:

plasmoidviewer(14515)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
plasmoidviewer(14515)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
plasmoidviewer(14515)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515): Failed to lock file "/var/tmp/kdecache-nikita/kpc/plasma_theme_default.lock" , last result = 2 
plasmoidviewer(14515)/kdecore (KConfigSkeleton) KCoreConfigSkeleton::writeConfig:
clicked
QProcessPrivate::createPipe: Cannot create pipe 0x2d1fd28: Too many open files
QSocketNotifier: Invalid socket specified
QProcessPrivate::createPipe: Cannot create pipe 0x2d1fd50: Too many open files
QSocketNotifier: Invalid socket specified
QProcessPrivate::createPipe: Cannot create pipe 0x2d1fd78: Too many open files
QSocketNotifier: Invalid socket specified
QProcessPrivate::createPipe: Cannot create pipe 0x2d1fe00: Too many open files
QProcessPrivate::createPipe: Cannot create pipe 0x2d1fe08: Too many open files
QSocketNotifier: Invalid socket specified
QSocketNotifier: Invalid socket specified
KCrash: Application 'plasmoidviewer' crashing...
sock_file=/home/nikita/.kde4/socket-razor/kdeinit4__0

[1]+  Stopped                 plasmoidviewer .


This is why a button is needed - to force opening a new file. These messages show that bug#232973 is probably the same issue. Plasma can't lock plasma_theme_default.lock so it can't show any icons.
Comment 3 Ulf Sauer 2010-04-21 14:17:20 UTC
I can confirm this on my machine.
Steps to reproduce:

1. Download Make-Progress Engine 0.1.1 and Plasmoid 0.1.0
http://nikita.melnichenko.name/download.php?q=make-progress-latest.engine
http://nikita.melnichenko.name/download.php?q=make-progress-0.1.0.plasmoid

2. Install engine
$ plasmapkg -u make-progress-0.1.1.engine -t dataengine

3. Extract and start plasmoid
$ unzip make-progress-0.1.0.plasmoid -d plasmoid-make-progress
$ plasmoidviewer plasmoid-make-progress

4A. Add one long timer (min. 4 minutes) manually or via dbus, then start it
$ TIMER=$(qdbus name.melnichenko.nikita.make-progress.plasmoid / AddItem Timer); qdbus name.melnichenko.nikita.make-progress.plasmoid /$TIMER SetMaximum 240000; qdbus name.melnichenko.nikita.make-progress.plasmoid /$TIMER Start

4B. Instead of using one long timer, you can add multiple short timers (e.g. 8 x 10 seconds). This way you do not have to wait 4 minutes ;)
$ for i in {1..8};do TIMER=$(qdbus name.melnichenko.nikita.make-progress.plasmoid / AddItem Timer);qdbus name.melnichenko.nikita.make-progress.plasmoid /$TIMER SetMaximum 10000; qdbus name.melnichenko.nikita.make-progress.plasmoid /$TIMER Start;sleep 1s; done

5. plasmoidviewer/plasma crashes as soon as the first timer is done.

Versions:
KDE SC: 4.4.2
Qt: 4.6.2
Python: 2.6.4
PyQt: 4.7.2


end of output:
[...]
[Make progress!] Notification: Task e3 is complete.
QProcessPrivate::createPipe: Cannot create pipe 0xab108e0: Too many open files
QSocketNotifier: Invalid socket specified
QProcessPrivate::createPipe: Cannot create pipe 0xab108f8: Too many open files
QSocketNotifier: Invalid socket specified
QProcessPrivate::createPipe: Cannot create pipe 0xab10910: Too many open files
QSocketNotifier: Invalid socket specified
QProcessPrivate::createPipe: Cannot create pipe 0xab10970: Too many open files
QProcessPrivate::createPipe: Cannot create pipe 0xab10978: Too many open files
QSocketNotifier: Invalid socket specified
QSocketNotifier: Invalid socket specified
KCrash: Application 'plasmoidviewer' crashing...


Crashlog:
 Application: Plasma-Miniprogramm-Anzeige (plasmoidviewer), signal: Segmentation fault
[Current thread is 1 (Thread 0xb77b4710 (LWP 10270))]

Thread 2 (Thread 0xac643b70 (LWP 10272)):
#0  0x00e75422 in __kernel_vsyscall ()
#1  0x00dcbe15 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/tls/i686/cmov/libpthread.so.0
#2  0x0354487d in pthread_cond_wait () from /lib/tls/i686/cmov/libc.so.6
#3  0x02ba6887 in ?? () from /usr/lib/libQtScript.so.4
#4  0x02ba68d1 in ?? () from /usr/lib/libQtScript.so.4
#5  0x00dc780e in start_thread () from /lib/tls/i686/cmov/libpthread.so.0
#6  0x035378de in clone () from /lib/tls/i686/cmov/libc.so.6

Thread 1 (Thread 0xb77b4710 (LWP 10270)):
[KCrash Handler]
#6  0x009a2869 in ?? () from /usr/lib/libQtCore.so.4
#7  0x0095ef7f in QProcess::waitForStarted(int) () from /usr/lib/libQtCore.so.4
#8  0x01a3b4d5 in ?? () from /usr/lib/libkio.so.5
#9  0x01a3b562 in ?? () from /usr/lib/libkio.so.5
#10 0x01a3c362 in ?? () from /usr/lib/libkio.so.5
#11 0x01a3c9ee in KRun::runCommand(QString const&, QString const&, QString const&, QWidget*, QByteArray const&, QString const&) () from /usr/lib/libkio.so.5
#12 0x01a3cc58 in KRun::runCommand(QString const&, QWidget*, QString const&) () from /usr/lib/libkio.so.5
#13 0x01a3ce6a in KRun::runCommand(QString const&, QWidget*) () from /usr/lib/libkio.so.5
#14 0x081ea5df in ?? () from /usr/lib/kde4/plasma_appletscript_simple_javascript.so
#15 0x02beb07b in ?? () from /usr/lib/libQtScript.so.4
#16 0x02b12db0 in ?? () from /usr/lib/libQtScript.so.4
#17 0x02ab0c0c in ?? () from /usr/lib/libQtScript.so.4
#18 0x028c4737 in ?? ()
#19 0x02ad8471 in ?? () from /usr/lib/libQtScript.so.4
#20 0x02b41a1d in ?? () from /usr/lib/libQtScript.so.4
#21 0x02b12e0e in ?? () from /usr/lib/libQtScript.so.4
#22 0x02b49333 in ?? () from /usr/lib/libQtScript.so.4
#23 0x02beccc5 in ?? () from /usr/lib/libQtScript.so.4
#24 0x02ab0f1d in ?? () from /usr/lib/libQtScript.so.4
#25 0x028c0aad in ?? ()
#26 0x02ad8471 in ?? () from /usr/lib/libQtScript.so.4
#27 0x02b41a1d in ?? () from /usr/lib/libQtScript.so.4
#28 0x02b12e0e in ?? () from /usr/lib/libQtScript.so.4
#29 0x02bf7d63 in ?? () from /usr/lib/libQtScript.so.4
#30 0x02bf8146 in ?? () from /usr/lib/libQtScript.so.4
#31 0x009cde5a in QMetaObject::metacall(QObject*, QMetaObject::Call, int, void**) () from /usr/lib/libQtCore.so.4
#32 0x009dc5f5 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /usr/lib/libQtCore.so.4
#33 0x00a2dc97 in QTimer::timeout() () from /usr/lib/libQtCore.so.4
#34 0x009e479e in QTimer::timerEvent(QTimerEvent*) () from /usr/lib/libQtCore.so.4
#35 0x009d9494 in QObject::event(QEvent*) () from /usr/lib/libQtCore.so.4
#36 0x00fab3cc in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#37 0x00fb201e in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQtGui.so.4
#38 0x006595ba in KApplication::notify(QObject*, QEvent*) () from /usr/lib/libkdeui.so.5
#39 0x009c8beb in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/libQtCore.so.4
#40 0x009f7eb6 in ?? () from /usr/lib/libQtCore.so.4
#41 0x009f4b47 in ?? () from /usr/lib/libQtCore.so.4
#42 0x01bfee88 in g_main_context_dispatch () from /lib/libglib-2.0.so.0
#43 0x01c02730 in ?? () from /lib/libglib-2.0.so.0
#44 0x01c02863 in g_main_context_iteration () from /lib/libglib-2.0.so.0
#45 0x009f4805 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#46 0x0106ab35 in ?? () from /usr/lib/libQtGui.so.4
#47 0x009c7209 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#48 0x009c765a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/libQtCore.so.4
#49 0x009cb84f in QCoreApplication::exec() () from /usr/lib/libQtCore.so.4
#50 0x00fab467 in QApplication::exec() () from /usr/lib/libQtGui.so.4
#51 0x08050bf7 in _start ()
Comment 4 Aaron J. Seigo 2010-05-08 01:43:27 UTC
what command is getting run (as apparently there is a call to runCommand there) and how often is it getting called?
Comment 5 Nikita Melnichenko 2010-05-08 16:00:37 UTC
It's a python, if I understood you right. Here it is:
plasmoid.runCommand("python", [ plasmoid.file("", "scripts/knotify.py"), "Notification",  "title",  "clicked", "3000"]);
Actually, it's not the reason because it just starts a new QProcess which needs a new file descriptor, and Plasma (or plasmoidviewer, whatever) is out of free descriptors at that moment. So it's just a "crash initiator", I believe.

The problem is somewhere between service.startOperationCall and plasmoid.dataUpdated. They are called very often. It seems that startOperationCall opens a new descriptor each time and forgets to close it. Something like that. That's why Plasma has no more descriptors in the moment of crash.

Have you tried to reproduce it with the attached plasmoid I specially created for this bug report? It's much smaller that Make Progress plasmoid and should be a good testcase. The crash can be reproduced every time on my system. I hope it could help you. Thanks for attention.
Comment 6 Nikita Melnichenko 2010-05-09 23:32:20 UTC
I spent few hours today by looking for the reason of descriptor leak. It seems I have found what's causing it. This knowledge even helped me to make a walk-around for this issue in my plasmoid.

The problem was in the serviceForSource. Each time it had been called, the new instance of Service object is created and registerOperationsScheme is called (which calls setOperationsScheme). It needs a QFile object and lives with it (don't understand why it should live with it, we probably need read-and-forget pattern here). For some reason (buggy Plasma?) the service objects are never freed, so the number of QFile objects increases (btw, the memory leak grows too). At some point Plasma can't open new files and crashes (here is the second bug).

The walk-around is to save created objects and return these instances on further requests. However this fix is not complete: user can actively create and delete progress items and we must create new instances of ServiceProgressProps class. Anyway, this walk-around covers the most of cases and needs to be applied.

To sum up. I think there are two bugs here:
1. Service objects are not freed, i.e. if serviceForSource returns a new object for the same source, older isn't destroyed.
2. When Plasma is out of file descriptors, runCommand makes segfault.

and one question:
Why descriptor is needed for service?
I looked through code of Service::setOperationsScheme and didn't understood FIXME message:
    //FIXME: make KSharedConfig and KConfigSkeleton not braindamaged in 4.2 and then get rid of the
    //       temp file object here
    d->tempFile = new KTemporaryFile;
    d->tempFile->open();

Here d->tempFile is probably a descriptor that lives with a service. It must be deleted right in the end of that function, isn't it?
Comment 7 KOPRajs 2010-05-26 16:12:14 UTC
*** This bug has been confirmed by popular vote. ***
Comment 8 Aaron J. Seigo 2010-05-26 18:00:00 UTC
"For some reason (buggy Plasma?) the service objects are never freed"

from the api documentation: "The service is parented to the DataEngine, but may be deleted by the caller when finished with it." I'll change "may be" to "should be", but the meaning should really be clear already: Service objects are created on demand and really belong to the caller.

"The walk-around is to save created objects and return these instances on
further requests"

if you are doing this in the DataEninge, then this will eventually lead to crashes due to dangling pointers being held on to by the various users of the DataEngine's services when one of them deletes a Service (which is not only valid, it's how Services should be used).

if you are caching the Service objects in the Plasmoid, then yes, that's the correct approach.

"Here d->tempFile is probably a descriptor that lives with a service. It must be
deleted right in the end of that function, isn't it?"

no, because that KConfig object is required to make all the KConfigGroup reading/writing work properly. it needs to live as long as the service does. the problem here is that there is no "in memory" KConfigBackend to be used with KConfigBase, which would make the entire thing not require any file access at all beyond reading in the .operations file when the service is created.

In any case, the root of this particular bug is due to holding on to service objects indefinitely; even without the file descriptors it will lead to a growing usage of memory. Fix the plasmoid. :)
Comment 9 Nikita Melnichenko 2010-05-30 17:53:09 UTC
Resolution DOWNSTREAM? Wait a minute...

First of all, it's a 100% reproducible crash that was obtained by using scripts only. The main point of all this scripting thing is the high level of security. No matter what you write in your scripts, the background layer should NEVER ever ever crash! The good thing is additional leak protection and check for infinite loops, however, it's not so important as crash-free bindings. As far as I see, this crash haven't been fixed yet.

Secondly, you're wrong that something is holding service objects intentionally. Please, consider the given code a little bit closely. Who is actually holding these objects? Is it the data engine? No, because (in the initial version) it creates objects and returns them without any caching. Is it the plasmoid? No, it always calls serviceForSource, stores service object as local variable in a function and totally forget it after service.startOperationCall. We can't destroy an object in Javascript as in C++ language, however, reference count should be = 0. Don't write "fix the plasmoid" without giving an idea how to fix it, please!

I know it's a complicated bug, but we, KDE people, must fearlessly face it and finally solve it ;).
Comment 10 Aaron J. Seigo 2010-06-05 00:01:34 UTC
"The good thing is additional leak protection and check for
infinite loops, however, it's not so important as crash-free bindings"

that's precisely what this bug was: lack of accounting for leak protection and infinite loops. that's something QtScript is supposed to be giving us in future releases (hopefully sooner rather that later).

in 4.5 a temporary file is no longer used for services, so the file handle exhaustion won't happen anymore.

still, if you allocate infinite amounts of memory in your plasmoid we still don't catch that, and can't right now (against, blocking on QtScript). fix the script in the meantime because your users won't like it being terminated either.