https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107235

            Bug ID: 107235
           Summary: m2/boot-bin/mc leaks file descriptors
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: modula2
          Assignee: gaius at gcc dot gnu.org
          Reporter: ro at gcc dot gnu.org
  Target Milestone: ---
            Target: *-*-solaris2.11

Building the current devel/modula-2 branch on Solaris 11.3/SPARC fails like
this:

m2/boot-bin/mc --olang=c++ --h-file-prefix=G
-I/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libs
-I/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-compiler
-I/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libiberty
-I/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-gcc --quiet  --gcc-config-system
--extended-opaque -o=m2/gm2-compiler-boot/M2GCCDeclare.c
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-compiler/M2GCCDeclare.mod
failed to open
/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-compiler/M2GCCDeclare.mod

(same for m2/gm2-libs/NumberIO.def).

Running mc under truss reveals

8687/1:        
open("/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libs/Debug.def",
O_RDONLY|O_XPG4OPEN) = 255
[...]
8687/1:        
open("/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-compiler/M2GCCDeclare.mod",
O_RDONLY|O_XPG4OPEN) Err#24 EMFILE
8687/1:         write(2, " f a i l e d   t o   o p".., 84)      = 84

The file is opened several times (and apparent never closed), but the last
attempt (which would use fd 256) fails with EMFILE.  This happens because
Solaris up to 11.3 has a low fd limit of 255.

Raising the resource limit to (say 1024) allows the open to succeed, but mc
fails again shortly thereafter due the the stdio's limit of 255 open files.

There's a work/hack around this by preloading

LD_PRELOAD_32=/usr/lib/extendedFILE.so.1

tjat allows the build to continue, but I'm pretty certain that mc leaks fds
here and could easily avoid this issue by closing files when they are no longer
needed.

Reply via email to