Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 331651 - app-admin/sudo-1.7.4 hogs CPU while waiting for child process
Summary: app-admin/sudo-1.7.4 hogs CPU while waiting for child process
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://www.gratisoft.us/bugzilla/show...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-08 14:22 UTC by Hugo Mildenberger
Modified: 2010-08-09 13:47 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hugo Mildenberger 2010-08-08 14:22:39 UTC
using sudo emerge something, sudo eats up >90% of the CPU time. htop s revealed that sudo continuosly calls waitpid(somepid, someaddress,WNOHANG|WSTOPPED) = 0.

There is typo in exec.c which probably caused this misbehaviour:


257             do {
258 #ifdef sudo_waitpid
259                 pid = sudo_waitpid(child, &status, WUNTRACED|WNOHANG);
260 #else
261                 pid = wait(&status);
262 #endif
263                 if (pid == child) {
264                     if (!log_io) {
265                         if (WIFSTOPPED(status)) {
266                             /* Child may not have privs to suspend us itself. */
267                             kill(getpid(), WSTOPSIG(status));
268                         } else {
269                             /* Child has exited, we are done. */
270                             cstat->type = CMD_WSTATUS;
271                             cstat->val = status;
272                             return 0;
273                         }
274                     }
275                     /* Else we get ECONNRESET on sv[0] if child dies. */
276                 }
277             } while (pid != -1 || errno == EINTR);


The last line should probably read:

277             } while (pid == -1 || errno == EINTR);
Comment 1 Hugo Mildenberger 2010-08-08 14:25:43 UTC
Sorry, there are two logical errors. Line 277 should read:

277             } while (pid == -1 && errno == EINTR);
Comment 2 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-08-08 16:55:30 UTC
Would you mind reporting this upstream?
Comment 3 Hugo Mildenberger 2010-08-08 17:42:32 UTC
(In reply to comment #2)
> Would you mind reporting this upstream?

I checked upstream in the meantime. Apparently, they rewrote much of exec.c, and the do - loop condition appears to be correct now. But if you think that reporting it still makes sense, I'll do.
Comment 4 Hugo Mildenberger 2010-08-09 08:29:12 UTC
app-admin/sudo-1.7.2_p7  and app-admin/sudo-1.7.3  appear also to be affected by this, one way or another. Look into sudo_edit.c instead of exec.c or do a "grep EINTR *.c". There is also a security issue pending (BUG #322517) for app-<=admin/sudo-1.7.2_p7.

Comment 5 Diego Elio Pettenò (RETIRED) gentoo-dev 2010-08-09 13:47:39 UTC
1.7.4_p2 was released today so I'll bump and remove 1.7.4. The security issue is just waiting GLSA; I wouldn't count this as an enormous problem to ask stable of the new version right away, but I'll track this faster.