From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6783A386C598 for ; Mon, 27 Jun 2022 14:00:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6783A386C598 Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-235-XkGfOFcsPhCEMKaYMXGp8w-1; Mon, 27 Jun 2022 10:00:30 -0400 X-MC-Unique: XkGfOFcsPhCEMKaYMXGp8w-1 Received: by mail-ed1-f71.google.com with SMTP id q18-20020a056402519200b004358ce90d97so7161822edd.4 for ; Mon, 27 Jun 2022 07:00:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Pi7jKNqGHI68xoRrw3Pg1MQf1jHL8ZxEr5UqUCD6awk=; b=tS3T/pBLuBioVfcDZ4lJs/IPrqRv/ksbuuSbgErabFGGqVdRmrLKH+UC2CuE8A21OG upJXYP3O4H6ZrufvVTxd1FPZHEktUiz9Ap5k6FaSy9EAO+brm5rG0UFuH3r/5qq9vbpk HzLLWYGoy6rtpPiZTflKNO9BuRNLMzNok3LEmFU34FAEMynkCbsJOZs0SEKe+Imfvsil ZmVmkF5MhZCqBUByWVHcro92GEC9rFX3urNZme+i8sUw2PbgcCJdjn3nXNmdL7k7moe6 a2e1UkUrKi88Agu7eVYEe+u3cZEdCvgTJfEYs8Y55WXYWfaHxBhNf2fQX0DVvjU7uTyL ic/w== X-Gm-Message-State: AJIora8NHbCFiVJdzT3HdE6w+RHHit+kVAtqhu+oTA6aXNZpPiRnbNVi iBUbRu6MX2/3NCHUT3a/cGehuZqb2+CmXIcGmJge5lArnhehg3SVagJXnRnpPEvTQtQRe5gltRS +AWe85pO7bi8eDDlWHjecsKfFeHMVTVY= X-Received: by 2002:a05:6402:3808:b0:435:5a6c:9dd9 with SMTP id es8-20020a056402380800b004355a6c9dd9mr16894854edb.368.1656338429479; Mon, 27 Jun 2022 07:00:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7wsuIhCEoFciTdASYcF2rcqXNUlQx1DmUEN1K2VoxtMskKGUuI+43mDcWYPIYZwyEJSIjEgR/Mmg6CI4jFlw= X-Received: by 2002:a05:6402:3808:b0:435:5a6c:9dd9 with SMTP id es8-20020a056402380800b004355a6c9dd9mr16894827edb.368.1656338429248; Mon, 27 Jun 2022 07:00:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Mon, 27 Jun 2022 15:00:18 +0100 Message-ID: Subject: Re: [PATCH] libstdc++-v3: check for openat To: Alexandre Oliva Cc: gcc Patches , "libstdc++" X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jun 2022 14:00:34 -0000 On Mon, 27 Jun 2022 at 14:32, Jonathan Wakely wrote: > > On Mon, 27 Jun 2022 at 14:05, Alexandre Oliva wrote: > > > > On Jun 27, 2022, Alexandre Oliva wrote: > > > > > It looks like the atp.pathname is missing the nonexistent_path > > > assigned to variable dir in test_pr99290, so we attempt to open > > > subdirs thereof as if with openat. > > > > This appears to be caused by the early return in fs::_Dir's ctor: > > > > _Dir(const fs::path& p, bool skip_permission_denied, bool nofollow, > > [[maybe_unused]] bool filename_only, error_code& ec) > > : _Dir_base(p.c_str(), skip_permission_denied, nofollow, ec) > > { > > #if _GLIBCXX_HAVE_DIRFD // && 0 > > if (filename_only) > > return; // Do not store path p when we aren't going to use it. > > #endif > > Yes, this needs a fix. If we don't have openat then we always need a > full path relative to the CWD, not just a filename relative to a file > descriptor for the parent directory. > > I think we need to store the directory's path if any of dirfd, openat > or unlinkat is missing. > > > > > > if (!ec) > > path = p; > > } > > > > but somehow disabling the early return to force the saving of path > > appears to break copy(): copy.cc's test01() succeeded without the '&& 0' > > that I've commented-out above, but started failing to create 'to' in the > > copy at line copy.cc:54 when I put it in to prevent the early return. > > > > Does that make any sense to you? > > No, I'll have to debug the test. I thought that not storing the path > was just an optimization (to avoid parsing, decomposing, and > allocating a path object that we will never use). If I add the && 0 (so we don't store the path) and bodge so that HAVE_OPENAT and HAVE_UNLINKAT are both undefined, I do not see any new FAIL in the filesystem/operations/copy.cc tests. filesystem::copy doesn't even use recursive_directory_iterator, and the filename_only bool should always be false for non-recursive directory_iterator, and so the early return should never happen anyway. (I do have an uncommitted patch to avoid storing that path in more cases, including for non-recursive directory iterators, but it still wouldn't be true for filesystem::copy).