🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #440

GDB 4.6 (SPARC, SunOS 4.1.2) forgets to close file descriptors

#440
From: Anund Lie
Date: Mon, 14 Sep 1992 16:38
169 lines
7010 bytes
GDB 4.6 forgets to close file descriptors in certain cases when the
"file" command is used to switch executable files.  After a number of
iterations the process runs out of file descriptors and hangs.  The
case where this happens seems to be when the program is dynamically
linked and the file command is used when the program is active.  In
the example below, it seems to be the two dynamic libraries which are
opened once more for each iteration.

Anund Lie
Department of Computer Systems and Telematics 
Norwegian Inst. of Technology, N-7034 Trondheim, Norway
Email: Anund.Lie@idt.unit.no       (Internet)


------------------------------------------------------------------------
villtind% cat t.c
int
main(argc,argv)
int argc;
char *argv[];
{
    return argc;
}
villtind% gcc -g -o t t.c
villtind% gdb t
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.6, Copyright 1992 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x22a4: file t.c, line 6.
(gdb) run
Starting program: /a/villtind/home/villtind/anund/t 

Breakpoint 1, main (argc=1, argv=0xf7fffbd4) at t.c:6
6	    return argc;
(gdb) 
Stopped
villtind% ls -li t t.c /usr/lib/libc.so.* /usr/lib/libdl.so.* /local/bin/gdb
 34345 -rwxr-xr-x  1 anund     2801664 Aug 12 15:02 /local/bin/gdb*
 31875 -rwxr-xr--  1 root       516096 May  7 00:38 /usr/lib/libc.so.1.7*
 31804 -rwxr-xr-x  1 root        24576 Oct 11  1990 /usr/lib/libdl.so.1.0*
 71588 -rwxr-xr-x  1 anund       24576 Sep 14 14:13 t*
 71576 -rw-r--r--  1 anund          65 Sep 14 14:12 t.c
villtind% ps ax | egrep gdb
18170 p4 T     0:00 gdb t
18180 p4 S     0:00 egrep gdb
villtind% ofiles 18170
user	 process command
anund    18170	 gdb           	
 cwd    = directory inode 71559 on local fs 707 (/a/villtind/home/villtind)
 fd #0  = character special device /dev/ttyp4
 fd #1  = character special device /dev/ttyp4
 fd #2  = character special device /dev/ttyp4
 fd #3  = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #4  = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #5  = file inode 31875 on local fs 706 (/usr)
 fd #6  = file inode 31875 on local fs 706 (/usr)
 fd #7  = file inode 31804 on local fs 706 (/usr)
 fd #8  = file inode 31804 on local fs 706 (/usr)
 mmap   = file inode 34345 on nfs fs 33280 (/local)
 mmap   = file inode 31804 on local fs 706 (/usr)
 mmap   = file inode 31804 on local fs 706 (/usr)
 mmap   = file inode 31875 on local fs 706 (/usr)
villtind% %gdb
gdb t
(gdb) file t
A program is being debugged already.  Kill it? (y or n) y
Load new symbol table from "t"? (y or n) y
Reading symbols from t...
Breakpoint 1 at 0x22a4: file t.c, line 6.
done.
(gdb) run
Starting program: /a/villtind/home/villtind/anund/t 

Breakpoint 1, main (argc=1, argv=0xf7fffbd4) at t.c:6
6	    return argc;
(gdb) 
Stopped
villtind% jobs
[1]  + Stopped              gdb t
villtind% !ofi
ofiles 18170
user	 process command
anund    18170	 gdb           	
 cwd    = directory inode 71559 on local fs 707 (/a/villtind/home/villtind)
 fd #0  = character special device /dev/ttyp4
 fd #1  = character special device /dev/ttyp4
 fd #2  = character special device /dev/ttyp4
 fd #3  = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #4  = file inode 31875 on local fs 706 (/usr)
 fd #5  = file inode 31875 on local fs 706 (/usr)
 fd #6  = file inode 31875 on local fs 706 (/usr)
 fd #7  = file inode 31804 on local fs 706 (/usr)
 fd #8  = file inode 31804 on local fs 706 (/usr)
 fd #9  = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #10 = file inode 31804 on local fs 706 (/usr)
 mmap   = file inode 34345 on nfs fs 33280 (/local)
villtind% %gdb
gdb t
(gdb) file t
A program is being debugged already.  Kill it? (y or n) y
Load new symbol table from "t"? (y or n) y
Reading symbols from t...
Breakpoint 1 at 0x22a4: file t.c, line 6.
done.
(gdb) run
Starting program: /a/villtind/home/villtind/anund/t 

Breakpoint 1, main (argc=1, argv=0xf7fffbd4) at t.c:6
6	    return argc;
(gdb) 
Stopped
villtind% !ofi
ofiles 18170
user	 process command
anund    18170	 gdb           	
 cwd    = directory inode 71559 on local fs 707 (/a/villtind/home/villtind)
 fd #0  = character special device /dev/ttyp4
 fd #1  = character special device /dev/ttyp4
 fd #2  = character special device /dev/ttyp4
 fd #3  = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #4  = file inode 31875 on local fs 706 (/usr)
 fd #5  = file inode 31875 on local fs 706 (/usr)
 fd #6  = file inode 31875 on local fs 706 (/usr)
 fd #7  = file inode 31875 on local fs 706 (/usr)
 fd #8  = file inode 31804 on local fs 706 (/usr)
 fd #9  = file inode 31804 on local fs 706 (/usr)
 fd #10 = file inode 31804 on local fs 706 (/usr)
 fd #11 = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #12 = file inode 31804 on local fs 706 (/usr)
 mmap   = file inode 34345 on nfs fs 33280 (/local)
villtind% %gdb
gdb t
(gdb) file t
A program is being debugged already.  Kill it? (y or n) y
Load new symbol table from "t"? (y or n) y
Reading symbols from t...
Breakpoint 1 at 0x22a4: file t.c, line 6.
done.
(gdb) run
Starting program: /a/villtind/home/villtind/anund/t 

Breakpoint 1, main (argc=1, argv=0xf7fffbd4) at t.c:6
6	    return argc;
(gdb) 
Stopped
villtind% !ofi
ofiles 18170
user	 process command
anund    18170	 gdb           	
 cwd    = directory inode 71559 on local fs 707 (/a/villtind/home/villtind)
 fd #0  = character special device /dev/ttyp4
 fd #1  = character special device /dev/ttyp4
 fd #2  = character special device /dev/ttyp4
 fd #3  = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #4  = file inode 31875 on local fs 706 (/usr)
 fd #5  = file inode 31875 on local fs 706 (/usr)
 fd #6  = file inode 31875 on local fs 706 (/usr)
 fd #7  = file inode 31875 on local fs 706 (/usr)
 fd #8  = file inode 31804 on local fs 706 (/usr)
 fd #9  = file inode 31875 on local fs 706 (/usr)
 fd #10 = file inode 31804 on local fs 706 (/usr)
 fd #11 = file inode 31804 on local fs 706 (/usr)
 fd #12 = file inode 31804 on local fs 706 (/usr)
 fd #13 = file inode 71588 on local fs 707 (/a/villtind/home/villtind)
 fd #14 = file inode 31804 on local fs 706 (/usr)
 mmap   = file inode 34345 on nfs fs 33280 (/local)
villtind% 
Technical Details
Message-ID: <199209141238.AA27738@loke.idt.unit.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!idt.unit.no!Anund.Lie

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gdb.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!idt.unit.no!Anund.Lie
From: Anund.Lie@idt.unit.no (Anund Lie)
Subject: GDB 4.6 (SPARC, SunOS 4.1.2) forgets to close file descriptors
Message-ID: <199209141238.AA27738@loke.idt.unit.no>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 14 Sep 1992 16:38:55 GMT
Approved: bug-gdb@prep.ai.mit.edu
Lines: 170