Bug 274246

Summary: Lot of kdevelop 'defunct' processes exceed ulimit setting
Product: [Applications] kdevelop Reporter: ichramm <jramirez.uy>
Component: Build tools: MakeAssignee: kdevelop-bugs-null
Status: RESOLVED UPSTREAM    
Severity: normal CC: aaronw, kde, lurer, manisandro, olig9
Priority: NOR    
Version: 4.2.1   
Target Milestone: 4.2.0   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: shows the 'ps -ax | grep kdevelop' output
Hello World simple project
Hello World simple project (corrected)
Sample project again
strace output
kdevelop console output (fragment)
gdb output log with 2 zombies at the very start of gdb
one more gdb log, after few nights of uptime; 8 zombies;
+1 more zombie

Description ichramm 2011-05-27 04:17:04 UTC
Created attachment 60366 [details]
shows the 'ps -ax | grep kdevelop' output

Version:           4.2.1 (using KDE 4.6.3) 
OS:                Linux

I'm working with Makefile-based projects, and everytime I build a project a lot of kdevelop <defuct> processed apperar on the 'ps ax' output.

This problem became critical when I started using -j3 as make argument (or setting the number of concurrent task on the project properties)

When using kdevelop for a while the maximum number of user processes is exeeded and hsit happens :-P.

If you need more info dont hesitate to contact me


Reproducible: Always

Steps to Reproduce:
Open or import a custom make project

Compile

Compile again

Run ps -ax | grep kdevelop

Actual Results:  
There are a lot of kdevelop 'defunct' processes

Expected Results:  
There should be only one kdevelop process running.

I'm using Fedora 15 x64.

I've also tested it on Kubuntu 10.10 and 11.04
Comment 1 Milian Wolff 2011-05-27 17:16:46 UTC
Could you attach a simple hello-world like project that I can import and use to reproduce this bug?
Comment 2 ichramm 2011-05-27 18:54:17 UTC
Created attachment 60392 [details]
Hello World simple project

This project has 4 source files so it has sense to use the -j3 option.
Comment 3 ichramm 2011-05-27 18:58:03 UTC
Created attachment 60393 [details]
Hello World simple project (corrected)
Comment 4 ichramm 2011-05-27 19:08:16 UTC
Created attachment 60398 [details]
Sample project again

It seems that there is a problem with the bug tracking system and the file-format auto-detection because the files that I've uploaded became corrupted.

I'm uploading this file as a binary (application/octet-stream)
Comment 5 Milian Wolff 2011-05-28 23:42:26 UTC
hI cannot reproduce this on my machine...

I imported the project as custom make file project, then build it. I see that make -j3 ... is run but ps aux | grep kdevelop shows no defunct kdevelop processes!

so - am I missing something? what platform are you using? can someone else reproduce?
Comment 6 ichramm 2011-05-29 05:00:46 UTC
(In reply to comment #5)

I am working on a fresh install of fedora 15 x64.

But now I cannot reproduce the problem!

Since I did a system update yesterday, I started checking the yum database...

I checked all yum packages and found a couple of inconsistencies, first, some packages had the suffix "rc1" (the kernel was one of them) and others where installed twice (different versions of libgcc, gcc and libstdc++).

So I can only attribute this problem to my distro, or some particular package that were updated yesterday.

Doing a google search I've found a post at fedoraforum.rg that descrives the same problem (good for me 'cause I'm not dreaming...): http://www.fedoraforum.org/forum/showthread.php?t=260033

Anyway, I cannot attribute this problem to kdevelop anymore, you are free to mark this bug as invalid if you think it's right.

Best regards, and thanks for your time

Juan
Comment 7 olig9 2012-06-01 11:14:57 UTC
I also have the problem that KDevelop 4.2.60 creates lots of defunct processes (ps shows several thousand at the moment). I think the number increases when moving the mouse over C++ code, which opens doc tooltips etc.

From strace output it seems that a thread is created, it does some work, writes a result over pipe to main process, closes the pipe, then the main process calls waitpid() with WNOHANG, then the thread exits. That would indicate that there is a race: kdevelop calls waitpid() too early (4.5 msec before the thread calls exit_group).

Attached is strace output and console output. The thread I looked at has PID 23856, the main process has PID 15355.

This happens on RHEL5; so maybe there is indeed something different on RedHat and Fedora that causes this problem.
Comment 8 olig9 2012-06-01 11:15:52 UTC
Created attachment 71495 [details]
strace output
Comment 9 olig9 2012-06-01 11:16:30 UTC
Created attachment 71496 [details]
kdevelop console output (fragment)
Comment 10 Marco S 2012-06-28 08:52:01 UTC
I still see this bug in Ubuntu 12.04 with kdevelop 4.3.1 (dev 4.8.3).
Comment 11 Milian Wolff 2012-11-11 13:13:02 UTC
*** Bug 309833 has been marked as a duplicate of this bug. ***
Comment 12 Milian Wolff 2012-11-11 13:13:59 UTC
I'd welcome if someone who can actually reproduce this spents some time on investigating the cause and submitting a patch. I can't help you here without seeing the issue in the first place...
Comment 13 Milian Wolff 2012-11-11 13:14:14 UTC
reopening
Comment 14 Sandro Mani 2012-11-11 16:17:44 UTC
A gdb catch fork shows that the problem is at projectmanagers/cmake/parser/cmakeparserutils.cpp::129:
129: p.start();
130:
131: if(!p.waitForFinished())
132: {
133:        kDebug() << "failed to execute:" << execName;
134: }

Enabling kdebugdialog I see
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: failed to execute: ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: executed "" < ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: Executing: "" :: ("--help-variable-list")
kdevelop(2009)/kdecore (kdelibs) KTempDir::create: KTempDir: Temporary directory created : "/tmp/kde-sandro/kdevcmakemanagerz47iqy/"
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: failed to execute: ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: executed "" < ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: Executing: "" :: ("--help-module-list")
kdevelop(2009)/kdecore (kdelibs) KTempDir::create: KTempDir: Temporary directory created : "/tmp/kde-sandro/kdevcmakemanageraBv2ON/"
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: failed to execute: ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: executed "" < ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: Executing: "" :: ("--help-property-list")
kdevelop(2009)/kdecore (kdelibs) KTempDir::create: KTempDir: Temporary directory created : "/tmp/kde-sandro/kdevcmakemanagerb2yKf3/"
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: failed to execute: ""
kdevelop(2009)/kdevelop (cmake support debug) CMakeParserUtils::executeProcess: executed "" < ""
Those four executeProcess are the four zombies that get created every time I hover over a symbol. I guess one needs to ensure that the KProcess is terminated properly (though apparently it is already terminated when waitForFinished fails?
Comment 15 Sandro Mani 2012-11-11 16:26:03 UTC
Aha! The problem is that I don't have cmake installed! Packaging bug? Though probably this should also be fixed at code level, i.e. detect a missing cmake?
Comment 16 Milian Wolff 2012-11-11 17:31:57 UTC
Git commit 6987de41c2832de1fd42a1da17fef0b4c3f0bed5 by Milian Wolff.
Committed on 11/11/2012 at 18:30.
Pushed by mwolff into branch 'master'.

The CMake plugins have a runtime dependency on CMake, catch that properly.

M  +14   -0    projectmanagers/cmake/cmakedocumentation.cpp
M  +4    -0    projectmanagers/cmake/cmakedocumentation.h
M  +14   -0    projectmanagers/cmake/cmakemanager.cpp
M  +4    -0    projectmanagers/cmake/cmakemanager.h
M  +1    -0    projectmanagers/cmake/parser/cmakeparserutils.cpp

http://commits.kde.org/kdevelop/6987de41c2832de1fd42a1da17fef0b4c3f0bed5
Comment 17 Sandro Mani 2012-11-11 18:29:17 UTC
Tested -> works. Thanks!
Comment 18 Vadim A. Misbakh-Soloviov (mva) 2015-07-27 17:38:04 UTC
Hi guys!
Despite this bug is marked as fixed, I experience lots of kdevelop zombie processes just by running kdevelop instance with all plugins disabled.
Project doesn't use CMake. There is just web-application on Lua + custom makefile.

When I start kdevelop, there is already one zombie process. After some time (about 5-10 minutes) there is second one appears. hat so, after the night with open KDevelop I've tons zombie forks. And after a week or even month — I start to experience problems with starting new processes :-/

Can I provide some more usefull info to fix that entirely?
Comment 19 Milian Wolff 2015-07-30 11:01:18 UTC
Yes, if you can reproduce this issue, please try the following:

gdb kdevelop
...
(gdb) break fork
(gdb) command 1
> bt
> cont
> end
(gdb) set pagination off
(gdb)  run -s name-of-your-session
...

This will output backtraces whenever a process is forked of using QProcess. This should not happen often, and you should be able to track the output and tell us where it tries to run applicatoins from. This is already useful information, and maybe you can figure out where the zombie comes from.
Comment 20 Vadim A. Misbakh-Soloviov (mva) 2015-08-02 15:12:19 UTC
Created attachment 93846 [details]
gdb output log with 2 zombies at the very start of gdb

Thanks a lot!

I've attached entire gdb log with commands you've suggested. It is already 2 zombie-threads, while I do not touch it yet (I mean, I just opened kdevelop and don't write a single line of code, but there is 2 zombies already).

Debugging continues...
Comment 21 Vadim A. Misbakh-Soloviov (mva) 2015-08-07 10:33:19 UTC
Created attachment 93929 [details]
one more gdb log, after few nights of uptime; 8 zombies;

Hi! there is one more log, after few days of kdevelop uptime; There is 8 zombies already. And, it seems, zombies appears only when I do coding (using autocomplete, and so on). So, I'd think it is somehow related to code autocompletion (either popup or code scanning). I'd also suggest some git calls on file saving, but it isn't reproduce by random save operations and, moreover, zombies appears even if I disable all modules, including git.
Comment 22 Vadim A. Misbakh-Soloviov (mva) 2015-08-07 10:37:21 UTC
Created attachment 93930 [details]
+1 more zombie

I also opened KDevelop settings dialog while writing previous comment and noticed one more zombie and some log addition.

Although, there is some localized messages (I forgot to run that instance of KDevelop with LC_ALL=en_US.UTF-8, sorry), so, if you interested in content of one of such line - I'd translate it for you.
Comment 23 Milian Wolff 2015-08-09 22:05:37 UTC
Comment on attachment 93929 [details]
one more gdb log, after few nights of uptime; 8 zombies;

You seem to have the lumen plugin enabled - do you have dcd-client and dcd-server in your $PATH?
Comment 24 Vadim A. Misbakh-Soloviov (mva) 2015-08-09 23:38:37 UTC
(In reply to Milian Wolff from comment #23)
> Comment on attachment 93929 [details]
> one more gdb log, after few nights of uptime; 8 zombies;
> 
> You seem to have the lumen plugin enabled - do you have dcd-client and
> dcd-server in your $PATH?

1) I can't find such plugin in KDevelop plugins list :(
2) no, I have no such binaries (and, moreover, searching for such binaries over distro's packages database gives me no result).
Comment 25 Milian Wolff 2015-08-10 09:35:42 UTC
It's a Kate plugin, try to disable it from the editor settings. Does this fix your issue? If so, we know what to fix.
Comment 26 Vadim A. Misbakh-Soloviov (mva) 2015-08-10 13:00:51 UTC
Yeah, it seems, it fixed issue. Thanks a lot!

// At least, KDevelop started without 2 initial zombies ;)

P.S. I'll comment here if they'll appear during workflow.
Comment 27 Vadim A. Misbakh-Soloviov (mva) 2015-08-14 10:26:27 UTC
So, it still no zombies appeared. I seems, you were right about D-lang completion katepart plugin. Thanks a lot ;)
Comment 28 Kevin Funk 2015-09-08 14:15:47 UTC
Assuming this fixed in Qt 5.5.0 (by https://bugreports.qt.io/browse/QTBUG-5990)
Comment 29 Aaron Williams 2016-01-09 00:02:08 UTC
I am seeing this happening with 4.7.1 on OpenSUSE 13.2 with a large project I am working on. One thing to note is that I have well over 100 files, .c, .h and .dts (device tree) files open in my project.