From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C50938582BC; Wed, 12 Oct 2022 12:21:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C50938582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665577267; bh=vtq5FmSKshyFaG274IxeY0tpA4zEg/ZmCZLrfv4sQTM=; h=From:To:Subject:Date:From; b=kZgtiZrbCvhDdNjPiTkijcARD2QmHDYi4d0DTGMDHX9qqNLrLMv5Bc0uv193WVM+W zYXvamEdZJp0/7RbCYaZco+KHuGlFm7T02+EWpG2n2Le/+sfzxz/2hesz3Jh6LzlVK nh9TnK0VGtGvjX9roR0917tloqf1fbGrSRwcv5PQ= From: "ro at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/107235] New: m2/boot-bin/mc leaks file descriptors Date: Wed, 12 Oct 2022 12:21:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ro at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107235 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=3Dc++ --h-file-prefix=3DG -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-syst= em --extended-opaque -o=3Dm2/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:=20=20=20=20=20=20=20=20 open("/vol/gcc/src/hg/master/modula-2/gcc/m2/gm2-libs/Debug.def", O_RDONLY|O_XPG4OPEN) =3D 255 [...] 8687/1:=20=20=20=20=20=20=20=20 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) =3D 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=3D/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 lo= nger needed.=