{"id":2226192,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2226192/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub6eebc2.gcc.gcc-TEST.redi.13.1.1@forge-stage.sourceware.org/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.1/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<bmm.hhub6eebc2.gcc.gcc-TEST.redi.13.1.1@forge-stage.sourceware.org>","date":"2026-04-22T10:23:06","name":"[v1,1/2] libstdc++: Enable debug assertions for filesystem directory iterators","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"301e67a3b121b71704bb2ca7969e2bbf983f4879","submitter":{"id":93210,"url":"http://patchwork.ozlabs.org/api/1.1/people/93210/?format=json","name":"Jonathan Wakely via Sourceware Forge","email":"forge-bot+redi@forge-stage.sourceware.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/bmm.hhub6eebc2.gcc.gcc-TEST.redi.13.1.1@forge-stage.sourceware.org/mbox/","series":[{"id":500968,"url":"http://patchwork.ozlabs.org/api/1.1/series/500968/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=500968","date":"2026-04-22T10:23:05","name":"Better assertions from filesystem directory iterators and shared_ptr","version":1,"mbox":"http://patchwork.ozlabs.org/series/500968/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226192/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226192/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org; dmarc=none (p=none dis=none)\n header.from=forge-stage.sourceware.org","sourceware.org;\n spf=pass smtp.mailfrom=forge-stage.sourceware.org","server2.sourceware.org;\n arc=none smtp.remote-ip=38.145.34.39"],"Received":["from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0wd1505hz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 20:36:37 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 562EB4339F4D\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 10:36:35 +0000 (GMT)","from forge-stage.sourceware.org (vm08.sourceware.org [38.145.34.39])\n by sourceware.org (Postfix) with ESMTPS id ED6874BAE7E4\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:23:57 +0000 (GMT)","from forge-stage.sourceware.org (localhost [IPv6:::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256)\n (No client certificate requested)\n by forge-stage.sourceware.org (Postfix) with ESMTPS id C80B440574\n for <gcc-patches@gcc.gnu.org>; Wed, 22 Apr 2026 10:23:57 +0000 (UTC)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 562EB4339F4D","OpenDKIM Filter v2.11.0 sourceware.org ED6874BAE7E4"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org ED6874BAE7E4","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org ED6874BAE7E4","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776853438; cv=none;\n b=Z+j7Z5GiYknaBOB9g7qHjiksfkOJVzOmmVxwtqSUtRLtUTc2lvxPJTPTAoCziZ/yyeDi1MYkLthIZVdvToyHws1qsnFyuAZAW1RV8lVsedYSir7RPEY9mQvjvAmxa6Ky0L/mLABQKkdyqN7cXP1nGrgFz2r5t1G0fgf5PM3SRyA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776853438; c=relaxed/simple;\n bh=esZI/lu3T1cNUQOC6bD1QoFgfJ3JdpmuIRoR+h95jhg=;\n h=From:Date:Subject:To:Message-ID;\n b=O4cYfR3rD9jj3YOeaLdkj7xZR4R8oZW+aQsqDdLltnKGOV3ytOvF7Yf0J/WeT2zat5j7BMGa9RwX6qG92xMxlTupEgPEX3n9bknzXflnuuy4xebyjGtntS3aURaYPI4VPaSf2Se+cRGGtCoGCE1iMXkmCPJdgl408K6feRRMS5o=","ARC-Authentication-Results":"i=1; server2.sourceware.org","From":"Jonathan Wakely via Sourceware Forge\n <forge-bot+redi@forge-stage.sourceware.org>","Date":"Wed, 22 Apr 2026 10:23:06 +0000","Subject":"[PATCH v1 1/2] libstdc++: Enable debug assertions for filesystem\n directory iterators","To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>","Message-ID":"\n <bmm.hhub6eebc2.gcc.gcc-TEST.redi.13.1.1@forge-stage.sourceware.org>","X-Mailer":"batrachomyomachia","X-Pull-Request-Organization":"gcc","X-Pull-Request-Repository":"gcc-TEST","X-Pull-Request":"https://forge.sourceware.org/gcc/gcc-TEST/pulls/13","References":"\n <bmm.hhub6eebc2.gcc.gcc-TEST.redi.13.1.0@forge-stage.sourceware.org>","In-Reply-To":"\n <bmm.hhub6eebc2.gcc.gcc-TEST.redi.13.1.0@forge-stage.sourceware.org>","X-Patch-URL":"\n https://forge.sourceware.org/redi/gcc/commit/6ed99003c8330137e722eac9b8639f74e4497051","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Reply-To":"gcc-patches mailing list <gcc-patches@gcc.gnu.org>, redi@gcc.gnu.org","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"From: Jonathan Wakely <jwakely@redhat.com>\n\nSeveral member functions of filesystem::directory_iterator and\nfilesystem::recursive_directory_iterator currently dereference their\nshared_ptr data member without checking for non-null. Because they use\noperator-> and that function only uses _GLIBCXX_DEBUG_PEDASSERT rather\nthan __glibcxx_assert there is no assertion even when the library is\nbuilt with _GLIBCXX_ASSERTIONS defined. This means that dereferencing\ninvalid directory iterators gives an unhelpful segfault.\n\nBy using (*p). instead of p-> we get an assertion when the library is\nbuilt with _GLIBCXX_ASSERTIONS, with a \"_M_get() != nullptr\" message.\n\nlibstdc++-v3/ChangeLog:\n\n\t* src/c++17/fs_dir.cc (fs::directory_iterator::operator*): Use\n\tshared_ptr::operator* instead of shared_ptr::operator->.\n\t(fs::recursive_directory_iterator::options): Likewise.\n\t(fs::recursive_directory_iterator::depth): Likewise.\n\t(fs::recursive_directory_iterator::recursion_pending): Likewise.\n\t(fs::recursive_directory_iterator::operator*): Likewise.\n\t(fs::recursive_directory_iterator::disable_recursion_pending):\n\tLikewise.\n---\n libstdc++-v3/src/c++17/fs_dir.cc | 12 ++++++------\n 1 file changed, 6 insertions(+), 6 deletions(-)","diff":"diff --git a/libstdc++-v3/src/c++17/fs_dir.cc b/libstdc++-v3/src/c++17/fs_dir.cc\nindex 28d27f6a9fa1..8fe9e5e4cc81 100644\n--- a/libstdc++-v3/src/c++17/fs_dir.cc\n+++ b/libstdc++-v3/src/c++17/fs_dir.cc\n@@ -230,7 +230,7 @@ directory_iterator(const path& p, directory_options options, error_code* ecptr)\n const fs::directory_entry&\n fs::directory_iterator::operator*() const noexcept\n {\n-  return _M_dir->entry;\n+  return (*_M_dir).entry;\n }\n \n fs::directory_iterator&\n@@ -327,25 +327,25 @@ fs::recursive_directory_iterator::~recursive_directory_iterator() = default;\n fs::directory_options\n fs::recursive_directory_iterator::options() const noexcept\n {\n-  return _M_dirs->options;\n+  return (*_M_dirs).options;\n }\n \n int\n fs::recursive_directory_iterator::depth() const noexcept\n {\n-  return int(_M_dirs->size()) - 1;\n+  return int((*_M_dirs).size()) - 1;\n }\n \n bool\n fs::recursive_directory_iterator::recursion_pending() const noexcept\n {\n-  return _M_dirs->pending;\n+  return (*_M_dirs).pending;\n }\n \n const fs::directory_entry&\n fs::recursive_directory_iterator::operator*() const noexcept\n {\n-  return _M_dirs->top().entry;\n+  return (*_M_dirs).top().entry;\n }\n \n fs::recursive_directory_iterator&\n@@ -453,7 +453,7 @@ fs::recursive_directory_iterator::pop()\n void\n fs::recursive_directory_iterator::disable_recursion_pending() noexcept\n {\n-  _M_dirs->pending = false;\n+  (*_M_dirs).pending = false;\n }\n \n // Used to implement filesystem::remove_all.\n","prefixes":["v1","1/2"]}