Bug 341551 - KDEvelop 4.7 crash because too many open files during CMake import
Summary: KDEvelop 4.7 crash because too many open files during CMake import
Status: RESOLVED WORKSFORME
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: 4.7.1
Platform: Compiled Sources macOS
: NOR crash
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords: drkonqi
Depends on:
Blocks:
 
Reported: 2014-12-04 17:11 UTC by RJVB
Modified: 2021-01-16 04:34 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description RJVB 2014-12-04 17:11:59 UTC
Application: kdevelop (4.7.0)
KDE Platform Version: 4.14.3 (Compiled from sources)
Qt Version: 4.8.6
Operating System: Darwin 13.3.0 x86_64
Distribution (Platform): MacPorts Packages

-- Information about the crash:
- What I was doing when the application crashed:
I created a new session and imported the toplevel CMakeLists.txt file from the lldb 3.5 source corresponding to the current Ubuntu lldb-3.5 packages (= svn201651). After a short wait, I saw errors like shown below on the terminal, and then DrKonqi.
I'd say that KDevelop shouldn't crash when it hits an open file limit, but rather handle that situation appropriately.

QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/tools
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/examples
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/test
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/unittests
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/docs
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/cmake/modules
QKqueueFileSystemWatcherEngine::addPaths: open: Too many open files
QFileSystemWatcher: failed to add paths: /Volumes/Debian/Users/bertin/work/src/new/llvm/llvm-toolchain-snapshot-3.5~svn201651/include/llvm/IR
KCrash: Application 'kdevelop' crashing...
KCrash: Attempting to start /opt/local/lib/kde4/libexec/drkonqi.app/Contents/MacOS/drkonqi directly

-- Backtrace:
Application: KDevelop (kdevelop), signal: Segmentation fault: 11
(lldb) process attach --pid 80876
Process 80876 stopped
Executable module set to "/opt/local/bin/kdevelop".
Architecture set to: x86_64-apple-macosx.
(lldb) set set term-width 200
(lldb) thread info
thread #1: tid = 0x4bc91e, 0x00007fff8cb85e20 libsystem_kernel.dylib`__wait4 + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP

(lldb) bt all
* thread #1: tid = 0x4bc91e, 0x00007fff8cb85e20 libsystem_kernel.dylib`__wait4 + 8, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff8cb85e20 libsystem_kernel.dylib`__wait4 + 8
    frame #1: 0x0000000109c21c8e libkdeui.5.dylib`KCrash::startProcess(int, char const**, bool) [inlined] startProcessInternal(argc=<unavailable>, directly=<unavailable>) + 265 at kcrash.cpp:556
    frame #2: 0x0000000109c21b85 libkdeui.5.dylib`KCrash::startProcess(argc=<unavailable>, argv=<unavailable>, waitAndExit=<unavailable>) + 21 at kcrash.cpp:538
    frame #3: 0x0000000109c20db9 libkdeui.5.dylib`KCrash::defaultCrashHandler(sig=<unavailable>) + 1209 at kcrash.cpp:441
    frame #4: 0x00007fff8fe965aa libsystem_platform.dylib`_sigtramp + 26
    frame #5: 0x00007fff8d5f9b23 libc++abi.dylib`__dynamic_cast + 313
    frame #6: 0x000000011308b235 kdevcmakemanager.so`CMakeCommitChangesJob::makeChanges(this=0x00007fb3fce29130) + 149 at cmakecommitchangesjob.cpp:231
    frame #7: 0x000000011306763b kdevcmakemanager.so`CMakeCommitChangesJob::qt_static_metacall(_o=<unavailable>, _c=<unavailable>, _id=<unavailable>, _a=<unavailable>) + 123 at moc_cmakecommitchangesjob.cpp:60
    frame #8: 0x000000010b2baf1e QtCore`QObject::event(this=0x00007fb3fce29130, e=<unavailable>) + 734 at qobject.cpp:1222
    frame #9: 0x000000010a29040c QtGui`QApplicationPrivate::notify_helper(this=<unavailable>, receiver=0x00007fb3fce29130, e=0x00007fb3fd187fc0) + 252 at qapplication.cpp:4565
    frame #10: 0x000000010a291b50 QtGui`QApplication::notify(this=<unavailable>, receiver=<unavailable>, e=<unavailable>) + 864 at qapplication.cpp:3947
    frame #11: 0x000000010b2a7516 QtCore`QCoreApplication::notifyInternal(this=<unavailable>, receiver=<unavailable>, event=<unavailable>) + 118 at qcoreapplication.cpp:953
    frame #12: 0x000000010b2a80d2 QtCore`QCoreApplicationPrivate::sendPostedEvents(receiver=0x0000000000000000, event_type=0, data=0x00007fb3fd187fc0) + 770 at qcoreapplication.h:231
    frame #13: 0x00007fff8b0f25b1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #14: 0x00007fff8b0e3c62 CoreFoundation`__CFRunLoopDoSources0 + 242
    frame #15: 0x00007fff8b0e33ef CoreFoundation`__CFRunLoopRun + 831
    frame #16: 0x00007fff8b0e2e75 CoreFoundation`CFRunLoopRunSpecific + 309
    frame #17: 0x00007fff92edaa0d HIToolbox`RunCurrentEventLoopInMode + 226
    frame #18: 0x00007fff92eda685 HIToolbox`ReceiveNextEventCommon + 173
    frame #19: 0x00007fff92eda5bc HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 65
    frame #20: 0x00007fff8e16d24e AppKit`_DPSNextEvent + 1434
    frame #21: 0x00007fff8e16c89b AppKit`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    frame #22: 0x00007fff8e16099c AppKit`-[NSApplication run] + 553
    frame #23: 0x000000010a244ba0 QtGui`QEventDispatcherMac::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 528
    frame #24: 0x000000010b2a48ad QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags(this=0x00007fff00000024) + 9 at qglobal.h:2319
    frame #25: 0x000000010b2a48a4 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags(this=0x00007fff00000024) at qglobal.h:2319
    frame #26: 0x000000010b2a48a4 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags<QEventLoop::ProcessEventsFlag>::operator|(this=<unavailable>, f=EventLoopExec) const + 59 at qeventloop.cpp:149
    frame #27: 0x000000010b2a4869 QtCore`QEventLoop::exec(this=0x00007fff57ae1d70, flags=(i = 0)) + 409 at qeventloop.cpp:204
    frame #28: 0x000000010b2a7ac7 QtCore`QCoreApplication::exec() + 199 at qcoreapplication.cpp:1225
    frame #29: 0x0000000108131b7a kdevelop`main(argc=<unavailable>, argv=<unavailable>) + 54042 at main.cpp:564
    frame #30: 0x00007fff8d6075fd libdyld.dylib`start + 1
    frame #31: 0x00007fff8d6075fd libdyld.dylib`start + 1

  thread #2: tid = 0x4bc921, 0x00007fff8cb86662 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff8cb86662 libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff905a1421 libdispatch.dylib`_dispatch_mgr_invoke + 239
    frame #2: 0x00007fff905a1136 libdispatch.dylib`_dispatch_mgr_thread + 52

  thread #3: tid = 0x4bc93d, 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10, name = 'com.apple.CFSocket.private'
    frame #0: 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10
    frame #1: 0x00007fff8b12fa03 CoreFoundation`__CFSocketManager + 867
    frame #2: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #3: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #4: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #4: tid = 0x4bc96b, 0x00007fff8cb81a1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #0: 0x00007fff8cb81a1a libsystem_kernel.dylib`mach_msg_trap + 10
    frame #1: 0x00007fff8cb80d18 libsystem_kernel.dylib`mach_msg + 64
    frame #2: 0x00007fff8b0e3f15 CoreFoundation`__CFRunLoopServiceMachPort + 181
    frame #3: 0x00007fff8b0e3539 CoreFoundation`__CFRunLoopRun + 1161
    frame #4: 0x00007fff8b0e2e75 CoreFoundation`CFRunLoopRunSpecific + 309
    frame #5: 0x00007fff8e30d05e AppKit`_NSEventThread + 144
    frame #6: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #7: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #8: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #5: tid = 0x4bca16, 0x00007fff8cb85716 libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'QThread'
    frame #0: 0x00007fff8cb85716 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff8f5d7c3b libsystem_pthread.dylib`_pthread_cond_wait + 727
    frame #2: 0x000000010b1a0e13 QtCore`QWaitConditionPrivate::wait(this=<unavailable>, time=<unavailable>) + 211
    frame #3: 0x000000010b1a0c6f QtCore`QWaitCondition::wait(this=0x00007fb3faf192a8, mutex=0x00007fb3faf192b0, time=1000) + 111 at qwaitcondition_unix.cpp:158
    frame #4: 0x000000010c2c9450 libkdevplatformlanguage.8.dylib`KDevelop::DUChainPrivate::CleanupThread::run(this=0x00007fb3faf19290) + 192 at duchain.cpp:283
    frame #5: 0x000000010b19f752 QtCore`QThreadPrivate::start(arg=<unavailable>) + 418 at qthread_unix.cpp:349
    frame #6: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #7: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #8: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #6: tid = 0x4bca5a, 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10, name = 'OutputFilterThread'
    frame #0: 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10
    frame #1: 0x000000010b2d2d04 QtCore`qt_safe_select(nfds=14, fdread=0x00007fb3f898ddb8, fdwrite=0x00007fb3f898e050, fdexcept=0x00007fb3f898e2e8, orig_timeout=<unavailable>) + 452 at qcore_unix.cpp:79
    frame #2: 0x000000010b2d5f0a QtCore`QEventDispatcherUNIXPrivate::doSelect(this=0x00007fb3f898dc00, flags=(i = 36), timeout=0x0000000000000000) + 794 at qeventdispatcher_unix.cpp:219
    frame #3: 0x000000010b2d7853 QtCore`QEventDispatcherUNIX::processEvents(this=0x00007fb3faecea00, flags=(i = 36)) + 227 at qeventdispatcher_unix.cpp:936
    frame #4: 0x000000010b2a48ad QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags(this=0x0000000100000024) + 9 at qglobal.h:2319
    frame #5: 0x000000010b2a48a4 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags(this=0x0000000100000024) at qglobal.h:2319
    frame #6: 0x000000010b2a48a4 QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) [inlined] QFlags<QEventLoop::ProcessEventsFlag>::operator|(this=<unavailable>, f=EventLoopExec) const + 59 at qeventloop.cpp:149
    frame #7: 0x000000010b2a4869 QtCore`QEventLoop::exec(this=0x000000011af5fe50, flags=(i = 0)) + 409 at qeventloop.cpp:204
    frame #8: 0x000000010b19dbf9 QtCore`QThread::exec(this=<unavailable>) + 217 at qthread.cpp:538
    frame #9: 0x000000010b19f752 QtCore`QThreadPrivate::start(arg=<unavailable>) + 418 at qthread_unix.cpp:349
    frame #10: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #11: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #12: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #7: tid = 0x4bca5b, 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10, name = 'QProcessManager'
    frame #0: 0x00007fff8cb859aa libsystem_kernel.dylib`__select + 10
    frame #1: 0x000000010b27c007 QtCore`QProcessManager::run(this=0x000000010b3f0020) + 135 at qprocess_unix.cpp:270
    frame #2: 0x000000010b19f752 QtCore`QThreadPrivate::start(arg=<unavailable>) + 418 at qthread_unix.cpp:349
    frame #3: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #4: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #5: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #8: tid = 0x4be314, 0x00007fff8cb85716 libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'ThreadWeaver::Thread'
    frame #0: 0x00007fff8cb85716 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff8f5d7c3b libsystem_pthread.dylib`_pthread_cond_wait + 727
    frame #2: 0x000000010b1a0da1 QtCore`QWaitConditionPrivate::wait(this=0x00007fb3fb2fbef0, time=18446744073709551615) + 97
    frame #3: 0x000000010b1a0c6f QtCore`QWaitCondition::wait(this=0x00007fb3fad92c18, mutex=0x00007fb3fb5debf0, time=18446744073709551615) + 111 at qwaitcondition_unix.cpp:158
    frame #4: 0x0000000108eb32cb libthreadweaver.4.dylib`ThreadWeaver::WeaverImpl::blockThreadUntilJobsAreBeingAssigned(this=<unavailable>, th=0x00007fb3fa8ebd30) + 187 at WeaverImpl.cpp:370
    frame #5: 0x0000000108eb6263 libthreadweaver.4.dylib`ThreadWeaver::WorkingHardState::applyForWork(this=0x00007fb3fa9d1fc0, th=0x00007fb3fa8ebd30, previous=<unavailable>) + 179 at WorkingHardState.cpp:68
    frame #6: 0x0000000108eb46e7 libthreadweaver.4.dylib`ThreadWeaver::Thread::run(this=0x00007fb3fa8ebd30) + 359 at Thread.cpp:98
    frame #7: 0x000000010b19f752 QtCore`QThreadPrivate::start(arg=<unavailable>) + 418 at qthread_unix.cpp:349
    frame #8: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #9: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #10: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #9: tid = 0x4be316, 0x00007fff8cb85716 libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'Thread (pooled)'
    frame #0: 0x00007fff8cb85716 libsystem_kernel.dylib`__psynch_cvwait + 10
    frame #1: 0x00007fff8f5d7c3b libsystem_pthread.dylib`_pthread_cond_wait + 727
    frame #2: 0x000000010b1a0e13 QtCore`QWaitConditionPrivate::wait(this=<unavailable>, time=<unavailable>) + 211
    frame #3: 0x000000010b1a0c6f QtCore`QWaitCondition::wait(this=0x00007fb3faf38470, mutex=0x00007fb3fcc2d968, time=30000) + 111 at qwaitcondition_unix.cpp:158
    frame #4: 0x000000010b19204d QtCore`QThreadPoolThread::run(this=0x00007fb3faf38460) + 573 at qthreadpool.cpp:142
    frame #5: 0x000000010b19f752 QtCore`QThreadPrivate::start(arg=<unavailable>) + 418 at qthread_unix.cpp:349
    frame #6: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #7: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #8: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13

  thread #10: tid = 0x4be3d1, 0x00007fff8cb8664a libsystem_kernel.dylib`kevent + 10, name = 'QKqueueFileSystemWatcherEngine'
    frame #0: 0x00007fff8cb8664a libsystem_kernel.dylib`kevent + 10
    frame #1: 0x000000010b28a6d9 QtCore`QKqueueFileSystemWatcherEngine::run(this=0x00007fb3fcd3d400) + 105 at qfilesystemwatcher_kqueue.cpp:254
    frame #2: 0x000000010b19f752 QtCore`QThreadPrivate::start(arg=<unavailable>) + 418 at qthread_unix.cpp:349
    frame #3: 0x00007fff8f5d5899 libsystem_pthread.dylib`_pthread_body + 138
    frame #4: 0x00007fff8f5d572a libsystem_pthread.dylib`_pthread_start + 137
    frame #5: 0x00007fff8f5d9fc9 libsystem_pthread.dylib`thread_start + 13
(lldb) detach
Process 80876 detached
(lldb) (lldb) quit

Possible duplicates by query: bug 341534, bug 341528, bug 341507, bug 341456, bug 341422.

Reported using DrKonqi
Comment 1 Kevin Funk 2014-12-04 22:02:04 UTC
Yep. That's a serious problem we need to fix. With this in place, it's impossible to parse larger code bases such as LLVM, or the Linux Kernel.

Aleix: This is still a issue in KF5, too, right?
Comment 2 RJVB 2015-09-09 14:50:07 UTC
I keep running into this issue, and I don't really understand what happens. It would seem that the crash occurs in the statement 

    CMakeFolderItem* folder = dynamic_cast<CMakeFolderItem*>(f);

which makes it about impossible to debug (it doesn't help that I'm using LTO nowadays and that makes clang strip debug info, apparently).
Looking at the ctors invoked by CMakeFolderItem::CMakeFolderItem I don't see any dependence on the result of QFileSystemWatcher::addPaths() (QKqueueFileSystemWatcherEngine::addPaths() on OS X as on Linux). Those functions themselves are supposed to handle the file limit situation by simply not adding any new paths, sadly without signalling the error other than tracking errno;

Is there a way to rewrite that dynamic_cast making it a bit easier to figure out what's going on?
Comment 3 RJVB 2015-09-09 15:35:31 UTC
Oh, and somehow errno is being set (to 24) *before* the open() call in QKqueueFileSystemWatcherEngine::addPaths() returns an error (and the function calls perror() to print it). So resetting errno before the addPaths() call and catching a change results in an overzealous handling of the situation, which causes the project load to stall indefinitely.
Comment 4 RJVB 2015-09-09 15:48:55 UTC
The following modification seems to prevent the crash, but doesn't of course prevent the other artefacts of having too many open files (including surprising errors like "2015-09-09 17:41:17.867 kdevelop[42536:507] Critical failure: the LastResort font is unavailable." in the OS X system log.

```
    ProjectFolderItem* f = m_parentItem;
    errno = 0;
    m_manager->addWatcher(m_project, m_path.toLocalFile());
    int addWatcherErrNo = errno;

    if(!m_projectDataAdded) {
        reloadFiles();
        return;
    }

    CMakeFolderItem* folder = NULL;
    if (addWatcherErrNo) {
        if (f) {
            folder = new CMakeFolderItem( f->project(), f->path(), f->path().lastPathSegment(), NULL);
        }
    }
    else {
        folder = dynamic_cast<CMakeFolderItem*>(f);
    }
```
Comment 5 Justin Zobel 2020-12-17 05:38:40 UTC
Thank you for the crash report.

As it has been a while since this was reported, can you please test and confirm if this issue is still occurring or if this bug report can be marked as resolved.

I have set the bug status to "needsinfo" pending your response, please change back to "reported" or "resolved/worksforme" when you respond, thank you.
Comment 6 Bug Janitor Service 2021-01-01 04:35:01 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Bug Janitor Service 2021-01-16 04:34:17 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!