bin/55346: /bin/sh eats memory and CPU infinitely

Eugene Grosbein eugen at kuzbass.ru
Sat Aug 16 20:51:45 PDT 2003


Doug White wrote:

> Ah, OK, I follow you there. send-pr away.

It seems that patch replaces memory leak with double-free bug:
waitforjob() will call freejob() just after dowait().

This corrected version removes extra freejob() call.

--- jobs.c.orig Mon Aug  4 11:48:00 2003
+++ jobs.c      Sun Aug 17 11:20:55 2003
@@ -889,8 +889,6 @@
 #endif
        else
                st = WTERMSIG(status) + 128;
-       if (! JOBS || jp->state == JOBDONE)
-               freejob(jp);
        if (int_pending()) {
                if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT)
                        kill(getpid(), SIGINT);
@@ -960,10 +958,8 @@
                                if (jp->state != state) {
                                        TRACE(("Job %d: changing state from %d
to %d\n", jp -
jobtab + 1, jp->state, state));
                                        jp->state = state;
-#if JOBS
                                        if (done)
-                                               deljob(jp);
-#endif
+                                               freejob(jp);
                                }
                        }
                }


Eugene Grosbein


More information about the freebsd-stable mailing list