From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 9AE143858025 for ; Fri, 13 Aug 2021 16:53:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9AE143858025 Received: by mail-lj1-x234.google.com with SMTP id n7so16599587ljq.0 for ; Fri, 13 Aug 2021 09:53:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UdvJzaxdLjQF608fl3P0V+yQz+A3psYWTnIxMAihg1s=; b=Fj+2m0eVKly32knitNuUoLwo34D7r9jTIJQHSi0+99eYy5qkoPzl+se/lUlB3SEQBd s6mAYGJblLqThEWzNldi77xfZYYxxNu2qfrtYTgg0kxXT6VuWxezu59H2fwSgKPySRZE 3wOV+g6swoJtXQSEuyO93GJLqc/RaNKTbh5FMx25io5zUKen8F7LRKLwfOX2oDGxD6Fx QhLEcNQ5fucIjofT4kCzrR+McWJlXWMjpVaJIu0gJ8AoMI0PzTPMo6ocRTz1jRf3g/3j cnh14c1XXl2IRrnQX4iFQiObTN8jEbdD98MFN+amw9ZLmxUBnT2crKDExrOQoCH3cLGq tyZA== X-Gm-Message-State: AOAM532AbHcCBsqpZlwGy5hlK/k/EA4m+z3QFEdnkQDrheqadEDvsaYV d9kehEAJYIaGC67rbkec9Pr7+/hTgEUWntWn+BKXQQ== X-Google-Smtp-Source: ABdhPJw6st8QYXDf/p0EBoeg3MSubrDd54bd0E+tkaGqqJdIpH1xsDiGP0g8M0R7UoQj2K9qjmuW90FFr4azoDjMq6A= X-Received: by 2002:a2e:bd11:: with SMTP id n17mr2602351ljq.480.1628873584875; Fri, 13 Aug 2021 09:53:04 -0700 (PDT) MIME-Version: 1.0 References: <20210812223336.3398471-1-slyich@gmail.com> <20210813080508.09afde43@zn3> In-Reply-To: <20210813080508.09afde43@zn3> From: Ian Lance Taylor Date: Fri, 13 Aug 2021 09:52:53 -0700 Message-ID: Subject: Re: [PATCH] libbacktrace: fix fd leak tests on systems with extra descriptors To: Sergei Trofimovich Cc: gcc-patches@gcc.gnu.org, Ian Lance Taylor , Sergei Trofimovich Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2021 16:53:11 -0000 On Fri, Aug 13, 2021 at 12:05 AM Sergei Trofimovich wrote: > > On Thu, 12 Aug 2021 16:16:04 -0700 > Ian Lance Taylor wrote: > > > On Thu, Aug 12, 2021 at 3:34 PM Sergei Trofimovich via Gcc-patches > > wrote: > > > > > > From: Sergei Trofimovich > > > > > > I noticed test failures when ran gcc test suite from under mc shell. > > > mc opens fd=9 and exposes it to child processes. As a result a few > > > tests failes: > > > FAIL: b2test_buildid > > > FAIL: btest_gnudebuglink > > > FAIL: btest > > > FAIL: btest_lto > > > FAIL: btest_alloc > > > FAIL: ctestg > > > FAIL: ctesta > > > FAIL: ctestg_alloc > > > FAIL: ctesta_alloc > > > FAIL: dwarf5 > > > FAIL: dwarf5_alloc > > > > > > Instead of trying to close file descripts in range test polls for > > > first available file descriptor by creating it via dup(1). > > > > > > libbacktrace/ > > > > > > * btest.c (check_open_files): Use last free file descriptor as a > > > signal for flie descriptor leak. > > > > This isn't a useful replacement, as this will pass as long as > > libbacktrace closes the first file descriptor that it opens. It won't > > check whether libbacktrace left any other file descriptors open. > > > > Perhaps at program startup we could fstat descriptors up to 10 and > > record whether they are valid, and then skip those files in > > check_open_files. > > Oh, great point! Completely missed it. Changed the patch to poll for present > file descriptors with fcntl(fd, F_GETFD) to compare before/after. I believe that we currently run some of the tests on Windows systems. Do you know if fcntl(fd, F_GETFD) will work there? Ian