[10536] in Athena Bugs

home help back first fref pref prev next nref lref last post

AIX 3.2 adb file descriptor leak

daemon@ATHENA.MIT.EDU (John Carr)
Sun Jun 6 06:37:16 1993

To: bugs@Athena.MIT.EDU
Date: Sun, 06 Jun 1993 06:37:11 EDT
From: John Carr <jfc@Athena.MIT.EDU>


This program demonstrates a file descriptor leak in AIX 3.2 adb.

----------------
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>

main(int argc, char *argv[])
{
  struct stat st;
  int i;

  for (i = 0; i < 64; i++)
    {
      if (fstat(i, &st) == -1)
	if (errno == EBADF)
	  continue;
	else
	  printf("%d: error %d\n", i, errno);
      printf("%d: dev %d, %d inode %d mode %o\n", i, st.st_dev >> 16,
	     st.st_dev & 0xffff, st.st_ino, st.st_mode);
    }
  return 0;
}
----------------

If run from a shell it prints:

0: dev 10, 5 inode 526 mode 21622
1: dev 10, 5 inode 526 mode 21622
2: dev 10, 5 inode 526 mode 21622

which is to be expected: 3 file descriptors are open and the rest are
closed.

If run from adb it prints:

0: dev 10, 5 inode 526 mode 21622
1: dev 10, 5 inode 526 mode 21622
2: dev 10, 5 inode 526 mode 21622
3: dev 32768, 19 inode 4118 mode 100775
5: dev 32768, 19 inode 4118 mode 100775

File descriptors 3 and 5 are the program.  If run again from adb even
more file descriptors are open:

0: dev 10, 5 inode 526 mode 21622
1: dev 10, 5 inode 526 mode 21622
2: dev 10, 5 inode 526 mode 21622
3: dev 32768, 19 inode 4118 mode 100775
4: dev 32768, 19 inode 4118 mode 100775
5: dev 32768, 19 inode 4118 mode 100775
6: dev 10, 6 inode 4207 mode 100555
7: dev 10, 6 inode 4207 mode 100555
8: dev 32768, 19 inode 4118 mode 100775
10: dev 32768, 19 inode 4118 mode 100775
14: dev 32768, 19 inode 4118 mode 100775
15: dev 32768, 19 inode 4118 mode 100775

Inode 4207 on device (10,6) is /usr/ccs/lib/libc.a.  This leak doesn't
seem to stop; I had adb using over 64 file descriptors after running
the program about 10-15 times.

Please report this to IBM.

"what /usr/bin/adb" says:

	22	1.12  R2/cmd/adb/opcode.c, bos, bos320 6/15/90 16:57:22
	17	1.15  com/cmd/adb/sym.c, bos, bos320 6/19/91 18:37:35
	%M  1.13  com/cmd/adb/output.c, bos, bos320  6/19/91  18:46:00
	19	1.9  R2/cmd/adb/extern.c, bos, bos320 6/15/90 16:57:07
	%M  1.13  com/cmd/adb/access.c, bos, bos320  6/19/91  18:36:27
	16	1.26  com/cmd/adb/setup.c, bos, bos320 6/19/91 18:37:31
	02	1.18  com/cmd/adb/expr.c, bos, bos320 6/19/91 18:36:35
	%M  1.9  com/cmd/adb/format.c, bos, bos320  6/19/91  18:36:43
	%M  1.17  com/cmd/adb/print.c, bos, bos320  6/19/91  18:37:23
	15	1.25  com/cmd/adb/runpcs.c, bos, bos320 6/19/91 18:37:27
	27  1.13  R2/cmd/adb/steps.c, bos, bos320 6/19/91 18:24:38
	00	1.15  com/cmd/adb/command.c, bos, bos320 6/19/91 18:36:30
	%M  1.14  com/cmd/adb/pcs.c, bos, bos320  6/19/91  18:37:19
	78  1.7  com/lib/ld/ldopen.c, bos, bos320 4/16/91 05:17:04
	62  1.4  com/lib/ld/allocldptr.c, bos, bos320 4/16/91 05:16:07
	68  1.3  com/lib/ld/lddef.h, bos, bos320 6/16/90 02:02:20
	20        1.21  R2/cmd/adb/machdep.c, bos, bos320 6/19/91 18:18:18
	65  1.7  com/lib/ld/ldahread.c, bos, bos320 4/16/91 05:16:18
	%M  1.15  com/cmd/adb/main.c, bos, bos320  6/19/91  18:37:03

home help back first fref pref prev next nref lref last post