bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug#102437: proc leaks memory with the bootstrap filesystem entry


From: Marcus Brinkmann
Subject: Bug#102437: proc leaks memory with the bootstrap filesystem entry
Date: Wed, 27 Jun 2001 11:26:53 +0200
User-agent: Mutt/1.3.18i

On Wed, Jun 27, 2001 at 03:59:03AM +0200, Marcus Brinkmann wrote:
> To prove that PID 4 is the only process with this
> problem, the below program iterates over all pids.  If you specify any command
> line arguments, it will skip PID 4.  In this case, no memory is leaked.

#define _GNU_SOURCE

#include <hurd.h>
#include <hurd/process.h>

int
main (int argc, char *argv[])
{
  int i;
  int err;
  mach_port_t proc = getproc();
  pid_t *pids;
  int pidslen;
  int flags = PI_FETCH_THREADS | PI_FETCH_THREAD_BASIC;
  int *piarray;
  int picount = 0;
  char *waits;
  int waitslen = 0;

  pids = 0;
  pidslen = 0;
  err =  proc_getallpids (proc, &pids, &pidslen);
  if (err)
    {
      printf ("%s: proc_getallpids(): %s\n", argv[0], strerror(errno));
      exit (1);
    }

  for (i = 0; i < pidslen; i++)
    {
      /* Specify an argument, and the symptoms go away.  */
      if (argc >= 2 && i == 4) 
        continue;
      piarray = waits = picount = waitslen = 0;

      err = proc_getprocinfo (proc, pids[i], &flags, &piarray, &picount, 
&waits, &waitslen);
      if (err)
        {
          printf ("%s: proc_getprocinfo() for %i: %s\n", argv[0], pids[i], 
strerror(errno));
          exit (1);
        }
        printf ("%i: %i, %i\n", pids[i], picount, waitslen);

      if (piarray)
        munmap (piarray, sizeof(int) * picount);
      if (waits)
        munmap (waits, sizeof(char) * waitslen);

    }
}

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd@debian.org
Marcus Brinkmann              GNU    http://www.gnu.org    marcus@gnu.org
Marcus.Brinkmann@ruhr-uni-bochum.de
http://www.marcus-brinkmann.de




reply via email to

[Prev in Thread] Current Thread [Next in Thread]