From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 374663858407 for ; Fri, 13 Aug 2021 22:05:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 374663858407 Received: by mail-wm1-x331.google.com with SMTP id 79-20020a1c0452000000b002e6cf79e572so1391938wme.1 for ; Fri, 13 Aug 2021 15:05:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0+cEkCJJp0cc/JZBizsTQTcRaFGe//7zZ+CIB9PMrZQ=; b=YjtZ+SRYxnL0IkT09c10YLvlSb9N9DRX2Yaii+mbaK8GmzFBPqo0OgsfTqSgJA0Gus nepXlJTVm0i1ZlI+fnWciCbrPfyVERaKzjXQfkQhhpx9GaITV65m0ATLEH1UOCvSXXN0 nJf6znGQz4B1tABfXQSPUCYReoVcKyff0xnCPfqeYspIf9ZbPmgJfzRlyY8cmBLPieUL mRp5QJHU9wK9da2opzpV7vPTOsZJ2gVRmzD/wBgEs4XJ+H11VAAUeLoZHwF9ocsQLVTD vyFuMm89tfKeR8gZuhuzZ5YMzdS51D9rvEasWy7Tq/420Bj5hXRupgTACfyj8F4In37H 7OCA== X-Gm-Message-State: AOAM530Yz3hx9Ekydf8K0tX0Q/bXErPvUXd54IWePZPyISWI4BugT0D5 t5ZF50tG/yt9/yXnLW5KPpc= X-Google-Smtp-Source: ABdhPJzt3Tej2oeuDQQ8EJUW/eSEPRRTD860atV9EOSJ4db2dEM39NT/H2tZFMoezmALXgg6ZeeZqg== X-Received: by 2002:a05:600c:2046:: with SMTP id p6mr4538329wmg.164.1628892345204; Fri, 13 Aug 2021 15:05:45 -0700 (PDT) Received: from zn3 (host81-129-83-184.range81-129.btcentralplus.com. [81.129.83.184]) by smtp.gmail.com with ESMTPSA id d7sm2861490wrs.39.2021.08.13.15.05.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Aug 2021 15:05:44 -0700 (PDT) Date: Fri, 13 Aug 2021 23:05:43 +0100 From: Sergei Trofimovich To: Ian Lance Taylor Cc: gcc-patches@gcc.gnu.org, Ian Lance Taylor , Sergei Trofimovich Subject: Re: [PATCH] libbacktrace: fix fd leak tests on systems with extra descriptors Message-ID: <20210813230536.0da745e9@zn3> In-Reply-To: References: <20210812223336.3398471-1-slyich@gmail.com> <20210813080508.09afde43@zn3> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.29; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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 22:05:49 -0000 On Fri, 13 Aug 2021 09:52:53 -0700 Ian Lance Taylor wrote: > 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? Ah, it does not. At least mingw does not expose fcntl. I'll look at possible equivalent on it and send another version. -- Sergei