Bug 310777

Summary: Crash - QProcess::waitForFinished - Running out of file descriptors
Product: [Unmaintained] nepomuk Reporter: Alban Pearce <alban>
Component: fileindexerAssignee: Nepomuk Bugs Coordination <nepomuk-bugs>
Status: RESOLVED FIXED    
Severity: crash CC: andy.boettger, axel.krebs, bart.deruyter, besenic.d, bladud, bradaffleck, bugzilla, cfeck, ch, cyberang3l, dns_hmpf, dobson187, fbrunnerreg, honkir, jbowler, johannes.schwall, kenny1, loic.grobol, m.wege, martin.runge, master.homer, me, mzanetti, oleg.atamanenko+kde, rdieter, rollin_brant, ronbu3, s5saso, sven.burmeister, thebigming, thothonegan
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 4.10.1
Sentry Crash Report:
Attachments: New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi
New crash information added by DrKonqi

Description Alban Pearce 2012-11-27 18:57:05 UTC
Application: nepomukservicestub (0.1.0)
KDE Platform Version: 4.9.80
Qt Version: 4.8.3
Operating System: Linux 3.7.0-3-generic x86_64
Distribution: Ubuntu Raring Ringtail (development branch)

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

useink Krapmail  Maybe Removing jnepomusk & akonadi  would result in a working system

The crash can be reproduced every time.

-- Backtrace:
Application: Nepomuk Service Stub (nepomukservicestub), signal: Aborted
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[KCrash Handler]
#6  0x00007f7056548e75 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:63
#7  0x00007f705654c4d8 in __GI_abort () at abort.c:90
#8  0x00007f70565854bb in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7f70566917cb "*** %s ***: %s terminated\n") at ../sysdeps/unix/sysv/linux/libc_fatal.c:200
#9  0x00007f7056620a8c in __GI___fortify_fail (msg=<optimized out>, msg@entry=0x7f7056691762 "buffer overflow detected") at fortify_fail.c:37
#10 0x00007f705661fa20 in __GI___chk_fail () at chk_fail.c:28
#11 0x00007f70566209d7 in __fdelt_chk (d=<optimized out>) at fdelt_chk.c:25
#12 0x00007f7058a54854 in QProcessPrivate::waitForStarted (this=0x1a33490, msecs=-1) at io/qprocess_unix.cpp:1038
#13 0x00007f7058a0ef53 in QProcess::waitForFinished (this=this@entry=0x7fff7440ac50, msecs=msecs@entry=-1) at io/qprocess.cpp:1752
#14 0x00007f7058a11569 in QProcess::execute (program=...) at io/qprocess.cpp:2176
#15 0x00007f70583afff1 in KSycocaPrivate::checkDatabase (this=0x137c890, ifNotFound=...) at ../../kdecore/sycoca/ksycoca.cpp:438
#16 0x00007f70583b0922 in KSycoca::findFactory (this=0x137c170, id=KST_KProtocolInfoFactory) at ../../kdecore/sycoca/ksycoca.cpp:462
#17 0x00007f70583b3ba7 in KSycocaFactory::KSycocaFactory (this=0x2adfa20, factory_id=KST_KProtocolInfoFactory) at ../../kdecore/sycoca/ksycocafactory.cpp:53
#18 0x00007f70583b7e33 in KProtocolInfoFactory::KProtocolInfoFactory (this=0x2adfa20) at ../../kdecore/sycoca/kprotocolinfofactory.cpp:29
#19 0x00007f70583b7f93 in self (this=0x14b97a0) at ../../kdecore/sycoca/ksycocafactory.h:200
#20 KProtocolInfoFactory::self () at ../../kdecore/sycoca/kprotocolinfofactory.cpp:121
#21 0x00007f70583206a4 in KMimeType::findByUrlHelper (_url=..., mode=mode@entry=0, is_local_file=is_local_file@entry=true, device=device@entry=0x7fff7440b040, accuracy=0x0) at ../../kdecore/services/kmimetype.cpp:282
#22 0x00007f7058320fd3 in KMimeType::findByUrl (url=..., mode=0, is_local_file=false, fast_mode=<optimized out>, accuracy=<optimized out>) at ../../kdecore/services/kmimetype.cpp:323
#23 0x00007f7047d383c8 in ?? () from /usr/lib/kde4/nepomukfileindexer.so
#24 0x00007f7047d2ff44 in ?? () from /usr/lib/kde4/nepomukfileindexer.so
#25 0x00007f7047d2cd7c in ?? () from /usr/lib/kde4/nepomukfileindexer.so
#26 0x00007f7058a8ef5f in QMetaObject::activate (sender=0x1fe1810, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff7440b4e0) at kernel/qobject.cpp:3547
#27 0x00007f70582ebcef in KJob::finished (this=this@entry=0x1fe1810, _t1=_t1@entry=0x1fe1810) at ./kjob.moc:187
#28 0x00007f70582ebf35 in KJob::emitResult (this=0x1fe1810) at ../../kdecore/jobs/kjob.cpp:316
#29 0x00007f705791af5f in ?? () from /usr/lib/libnepomukcore.so.4abi1
#30 0x00007f7058a8ef5f in QMetaObject::activate (sender=0x3790ff0, m=<optimized out>, local_signal_index=<optimized out>, argv=0x7fff7440b6d0) at kernel/qobject.cpp:3547
#31 0x00007f70586e213f in QDBusPendingCallWatcher::finished (this=<optimized out>, _t1=0x3790ff0) at .moc/release-shared/moc_qdbuspendingcall.cpp:106
#32 0x00007f7058a8e43e in QObject::event (this=0x3790ff0, e=<optimized out>) at kernel/qobject.cpp:1195
#33 0x00007f7056da3e9c in QApplicationPrivate::notify_helper (this=this@entry=0x11fcc90, receiver=receiver@entry=0x3790ff0, e=e@entry=0x13653f0) at kernel/qapplication.cpp:4562
#34 0x00007f7056da830a in QApplication::notify (this=0x7fff7440c1f0, receiver=0x3790ff0, e=0x13653f0) at kernel/qapplication.cpp:4423
#35 0x00007f7057daa386 in KApplication::notify (this=0x7fff7440c1f0, receiver=0x3790ff0, event=0x13653f0) at ../../kdeui/kernel/kapplication.cpp:311
#36 0x00007f7058a7956e in QCoreApplication::notifyInternal (this=0x7fff7440c1f0, receiver=receiver@entry=0x3790ff0, event=event@entry=0x13653f0) at kernel/qcoreapplication.cpp:915
#37 0x00007f7058a7d3f1 in sendEvent (event=0x13653f0, receiver=0x3790ff0) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:231
#38 QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x11d82c0) at kernel/qcoreapplication.cpp:1539
#39 0x00007f7058aa7a63 in sendPostedEvents () at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#40 postEventSourceDispatch (s=0x11f37c0) at kernel/qeventdispatcher_glib.cpp:279
#41 0x00007f7055a21a95 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#42 0x00007f7055a21dc8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#43 0x00007f7055a21e84 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#44 0x00007f7058aa7bf6 in QEventDispatcherGlib::processEvents (this=0x11d9780, flags=...) at kernel/qeventdispatcher_glib.cpp:424
#45 0x00007f7056e48c1e in QGuiEventDispatcherGlib::processEvents (this=<optimized out>, flags=...) at kernel/qguieventdispatcher_glib.cpp:204
#46 0x00007f7058a782bf in QEventLoop::processEvents (this=this@entry=0x7fff7440bfd0, flags=...) at kernel/qeventloop.cpp:149
#47 0x00007f7058a78548 in QEventLoop::exec (this=0x7fff7440bfd0, flags=...) at kernel/qeventloop.cpp:204
#48 0x00007f7058a7d708 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:1187
#49 0x0000000000403e00 in ?? ()
#50 0x00007f7056533c15 in __libc_start_main (main=0x403500, argc=2, ubp_av=0x7fff7440c438, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff7440c428) at libc-start.c:227
#51 0x0000000000404121 in _start ()

Possible duplicates by query: bug 310392, bug 309355, bug 309348, bug 309295, bug 309128.

Reported using DrKonqi
Comment 1 Simeon Bird 2012-11-29 15:43:14 UTC
Could you please post what *exactly* you were doing with kmail? Were you checking for mail? Was it indexing new mail? Does it crash on startup?

Similar reports suggest this can be caused by running out of file descriptors. 

What happens when you run kbuildsycoca4 from the command line? Does it also crash?

Could you (after the crash has occurred) verify this by finding the pid of the nepomukfileindexer process (look in top output for something called "nepomukservicestub nepomukfileindexer"). Once you have it, could you post the result of 

ls /proc/$pid/fd ?

Could you also post the result of ulimit -a?

Thanks
Comment 2 loic.grobol 2012-12-30 16:03:45 UTC
Created attachment 76094 [details]
New crash information added by DrKonqi

nepomukservicestub (0.1.0) on KDE Platform 4.9.95 using Qt 4.8.3

- What I was doing when the application crashed: right after logging in from the screen locker, DrKonqi started and signaled this crash. I have activated indexation for a new folder earlier today.

-- Backtrace (Reduced):
#6  0x00007fa4db564425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#7  0x00007fa4db567b8b in __GI_abort () at abort.c:91
[...]
#9  0x00007fa4db63882c in __GI___fortify_fail (msg=<optimized out>) at fortify_fail.c:38
#10 0x00007fa4db637700 in __GI___chk_fail () at chk_fail.c:29
#11 0x00007fa4db6387be in __fdelt_chk (d=<optimized out>) at fdelt_chk.c:26
Comment 3 Vishesh Handa 2013-01-07 09:28:22 UTC
*** Bug 312548 has been marked as a duplicate of this bug. ***
Comment 4 Vishesh Handa 2013-01-08 06:11:08 UTC
*** Bug 312547 has been marked as a duplicate of this bug. ***
Comment 5 Vishesh Handa 2013-01-09 08:29:24 UTC
*** Bug 312925 has been marked as a duplicate of this bug. ***
Comment 6 Oleg Atamanenko 2013-01-12 12:46:13 UTC
Created attachment 76418 [details]
New crash information added by DrKonqi

nepomukservicestub (0.1.0) on KDE Platform 4.9.97 using Qt 4.8.3

- Unusual behavior I noticed:
Nepomuk crashed without any reason.

-- Backtrace (Reduced):
#11 0x00007f1035b92854 in QProcessPrivate::waitForStarted (this=0x44d0ff0, msecs=30000) at io/qprocess_unix.cpp:1038
#12 0x00007f1035b4cf53 in QProcess::waitForFinished (this=0x2318f50, msecs=30000) at io/qprocess.cpp:1752
#13 0x00007f10249fa856 in Nepomuk2::FileIndexingJob::slotProcessTimerTimeout (this=0x2352d20) at ../../../services/fileindexer/fileindexingjob.cpp:118
[...]
#15 0x00007f1035bcc26c in QObject::event (this=0x3bfe690, e=<optimized out>) at kernel/qobject.cpp:1157
#16 0x00007f1033ee1e9c in QApplicationPrivate::notify_helper (this=this@entry=0x1f5a4d0, receiver=receiver@entry=0x3bfe690, e=e@entry=0x7fff592d2220) at kernel/qapplication.cpp:4562
Comment 7 Ronald Buckman 2013-01-15 04:56:27 UTC
Nepomukservicestub crashes when Chakra Linux is loaded and in other instances if using KDE 4.9.97.
Comment 8 loic.grobol 2013-01-17 13:01:24 UTC
Created attachment 76528 [details]
New crash information added by DrKonqi

nepomukservicestub (0.1.0) on KDE Platform 4.9.97 using Qt 4.8.3

- What I was doing when the application crashed: Nepomukservicestub crashed with no obvious reason or user interaction.

-- Backtrace (Reduced):
#6  0x00007f98ed53b425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#7  0x00007f98ed53eb8b in __GI_abort () at abort.c:91
[...]
#9  0x00007f98ed60f82c in __GI___fortify_fail (msg=<optimized out>) at fortify_fail.c:38
#10 0x00007f98ed60e700 in __GI___chk_fail () at chk_fail.c:29
#11 0x00007f98ed60f7be in __fdelt_chk (d=<optimized out>) at fdelt_chk.c:26
Comment 9 Vishesh Handa 2013-01-22 06:47:41 UTC
*** Bug 313664 has been marked as a duplicate of this bug. ***
Comment 10 Vishesh Handa 2013-01-22 06:49:57 UTC
*** Bug 313552 has been marked as a duplicate of this bug. ***
Comment 11 Vishesh Handa 2013-01-25 14:08:05 UTC
*** Bug 313713 has been marked as a duplicate of this bug. ***
Comment 12 Vishesh Handa 2013-01-26 13:45:44 UTC
Hey guys. Could you please provide the following information (preferably just after the crash)-

$ lsof | wc -l
$ sysctl fs.file-nr

The first command should give us the number of open files, and the second command will give us 3 numbers - <allocated file handles, unused but allocated file handles, maximum number of file handler>.
Comment 13 S. Burmeister 2013-01-27 20:10:51 UTC
Created attachment 76760 [details]
New crash information added by DrKonqi

nepomukservicestub (0.1.0) on KDE Platform 4.9.98 using Qt 4.8.4

- What I was doing when the application crashed:

Nepomuk crashed hile indexing new files in the background.

-- Backtrace (Reduced):
#12 0x00007fe6bd187f64 in QProcessPrivate::waitForStarted (this=0x34adc50, msecs=30000) at io/qprocess_unix.cpp:1030
#13 0x00007fe6bd142983 in QProcess::waitForFinished (this=0x33659c0, msecs=30000) at io/qprocess.cpp:1752
#14 0x00007fe6ae203036 in Nepomuk2::FileIndexingJob::slotProcessTimerTimeout (this=0x3472180) at /usr/src/debug/nepomuk-core-4.9.98/services/fileindexer/fileindexingjob.cpp:118
[...]
#16 0x00007fe6bd1c140c in QObject::event (this=0x30330b0, e=<optimized out>) at kernel/qobject.cpp:1165
#17 0x00007fe6bb29585c in QApplicationPrivate::notify_helper (this=this@entry=0xce7750, receiver=receiver@entry=0x30330b0, e=e@entry=0x7fffee7b92b0) at kernel/qapplication.cpp:4562
Comment 14 Christoph Feck 2013-01-29 14:35:50 UTC
Does Nepomuk use a QFileSystemWatcher per directory? As far as I see, each instance allocates an FD.
Comment 15 Vishesh Handa 2013-01-29 14:49:17 UTC
(In reply to comment #14)
> Does Nepomuk use a QFileSystemWatcher per directory? As far as I see, each
> instance allocates an FD.

Nope. We do allocate one inotify watch per directory, but that is NOT a file descriptor, and we have been doing that since 4.4 or 4.3
Comment 16 Christoph Feck 2013-02-05 00:05:36 UTC
*** Bug 314432 has been marked as a duplicate of this bug. ***
Comment 17 Christoph Feck 2013-02-05 00:07:20 UTC
Bug 314432 indicates that the indexer might try to start non-existant executables using QProcess, which due to a Qt bug, fails to cleanup pipes.
Comment 18 Christoph Feck 2013-02-05 00:11:18 UTC
*** Bug 313721 has been marked as a duplicate of this bug. ***
Comment 19 Mathias Tillman 2013-02-05 00:16:51 UTC
Well, QProcess creates a pipe so you can get a signal when the process exists. The problem here is that there are no checks in QProcess for this (except for the warning), and there is no way to check for that in the code.

Look at this mailing list for more information: http://www.mail-archive.com/nepomuk@kde.org/msg03539.html
Comment 20 Christoph Feck 2013-02-08 00:31:09 UTC
*** Bug 314257 has been marked as a duplicate of this bug. ***
Comment 21 Simeon Bird 2013-02-12 07:26:50 UTC
*** Bug 314965 has been marked as a duplicate of this bug. ***
Comment 22 Christoph Feck 2013-02-14 00:21:33 UTC
*** Bug 314986 has been marked as a duplicate of this bug. ***
Comment 23 Vishesh Handa 2013-02-14 07:57:55 UTC
It would be awesome if someone could test the patch over here - https://git.reviewboard.kde.org/r/108950/
Comment 24 Mathias Tillman 2013-02-14 10:25:35 UTC
@Vishesh Handa  I can confirm that the patch works, and that the crash was in fact due to it opening a descriptor for every directory (which in turn opened a pipe).
Comment 25 Vishesh Handa 2013-02-14 20:14:02 UTC
Git commit 630939e388beb4eaf6387a4f9bb827a87fdd0478 by Vishesh Handa.
Committed on 14/02/2013 at 08:40.
Pushed by vhanda into branch 'KDE/4.10'.

FileIndexer: Do not use QDirIterators in the queues

A DirIterator works by opening the directory (as a file) and reading its
contents, which are the list of files in that directory. As long as the
dirIterator is open, it consumes one file descriptor.

When iterating over all the folders, by using QDirIterator, we open a
new file descriptor per directory. Since we traverse the file system via
breadth first, the number of valid QDirIterators can get quite high.
This sometimes results in us exceeding the number of file descriptors
required which results in a crash, cause QProcess doesn't handle running
out of file descriptors.

Instead we now just iterate over all the directories and store them as
strings. This may consume more memory, but it is better than a crash.
REVIEW: 108950

M  +6    -33   services/fileindexer/basicindexingqueue.cpp
M  +0    -1    services/fileindexer/basicindexingqueue.h

http://commits.kde.org/nepomuk-core/630939e388beb4eaf6387a4f9bb827a87fdd0478
Comment 26 Christoph Feck 2013-02-14 22:28:18 UTC
Good job, merci!
Comment 27 Vishesh Handa 2013-02-15 08:20:47 UTC
*** Bug 315184 has been marked as a duplicate of this bug. ***
Comment 28 Vishesh Handa 2013-02-15 21:32:45 UTC
*** Bug 315236 has been marked as a duplicate of this bug. ***
Comment 29 Jekyll Wu 2013-02-16 06:10:53 UTC
*** Bug 315257 has been marked as a duplicate of this bug. ***
Comment 30 Jekyll Wu 2013-02-18 00:28:12 UTC
*** Bug 315342 has been marked as a duplicate of this bug. ***
Comment 31 Vishesh Handa 2013-02-19 16:29:26 UTC
*** Bug 315458 has been marked as a duplicate of this bug. ***
Comment 32 Vishesh Handa 2013-02-20 18:29:37 UTC
*** Bug 315532 has been marked as a duplicate of this bug. ***
Comment 33 Vishesh Handa 2013-02-21 18:28:25 UTC
*** Bug 315589 has been marked as a duplicate of this bug. ***
Comment 34 Vishesh Handa 2013-02-22 18:13:48 UTC
*** Bug 315634 has been marked as a duplicate of this bug. ***
Comment 35 Jekyll Wu 2013-02-25 01:07:13 UTC
*** Bug 315733 has been marked as a duplicate of this bug. ***
Comment 36 Christoph Feck 2013-02-26 22:31:18 UTC
*** Bug 315823 has been marked as a duplicate of this bug. ***
Comment 37 Vishesh Handa 2013-03-03 10:59:49 UTC
*** Bug 316052 has been marked as a duplicate of this bug. ***
Comment 38 Martin Runge 2013-03-04 20:09:29 UTC
Created attachment 77754 [details]
New crash information added by DrKonqi

nepomukservicestub (0.1.0) on KDE Platform 4.10.00 using Qt 4.8.3

- What I was doing when the application crashed:
Nothing, system was left alone idle

- Custom settings of the application:
Specified a proxy server in the office today, nepomuk crashed two times at home where this proxy is not in reach. I did not observe crashes before I set the proxy.

-- Backtrace (Reduced):
#5  0x00007f3ad2022425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#6  0x00007f3ad2025b8b in __GI_abort () at abort.c:91
[...]
#8  0x00007f3ad20f682c in __GI___fortify_fail (msg=<optimized out>) at fortify_fail.c:38
#9  0x00007f3ad20f5700 in __GI___chk_fail () at chk_fail.c:29
#10 0x00007f3ad20f67be in __fdelt_chk (d=<optimized out>) at fdelt_chk.c:26
Comment 39 duncan_mk 2013-06-27 14:59:16 UTC
I don't know whether this is a KDE or SuSE problem.  The substance of this e-mail is being sent to both.

## Output from Yast  Online Update
A package dependency could not be found.
More information is available in the detailed report:
# Detailed Report
patch:openSUSE-2013-456-1.noarch conflicts with libqt4-debuginfo.x86_64 < 4.8.4-3.6.1 provided by libqt4-debuginfo-4.8.4-3.3.1.x86_64

## Output from Yast  Online Update when the patch is excluded
This update is important as it may solve critical problems.
This update fixes the following issues with libqt4:
- Add check-return-value-of-qt_safe_pipe.patch:
  * fixes QTBUG#18934 and kde#310777
For more information about bugs fixed by this update please visit this website:
• https://bugs.kde.org/show_bug.cgi?id=310777
Repository: repo-update

#### YaST2 conflicts list - generated 2013-06-27 15:26:42 ####
patch:openSUSE-2013-456-1.noarch conflicts with libqt4-debuginfo.x86_64 < 4.8.4-3.6.1 provided by libqt4-debuginfo-4.8.4-3.3.1.x86_64

    [ ] deinstallation of libqt4-debuginfo-4.8.4-3.3.1.x86_64
    [ ] do not install patch:openSUSE-2013-456-1.noarch

#### YaST2 conflicts list END ###

############################################

System:    Host: linux-mn4n.site Kernel: 3.7.10-1.16-desktop x86_64 (64 bit, gcc: 4.7.2) 
           Desktop KDE 4.10.3 (Qt 4.8.4) Distro: openSUSE 12.3 (x86_64) VERSION = 12.3 CODENAME = Dartmouth                                                     
Machine:   System: SAMSUNG (portable) product: RV411/RV511/E3511/S3511/RV711    
           Mobo: SAMSUNG model: RV411/RV511/E3511/S3511/RV711 Bios: Phoenix version: 03PA.M001.20110312.XW date: 03/12/2011
CPU:       Dual core Intel Core i5 CPU M 480 (-HT-MCP-) cache: 3072 KB flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 10640.2                      
           Clock Speeds: 1: 2667.00 MHz 2: 1199.00 MHz 3: 1199.00 MHz 4: 1199.00 MHz
Comment 40 Christoph Feck 2013-07-03 23:22:42 UTC
Duncan, please don't add unrelated reports to bugs, but file a new one instead.