Message ID | or5ydvemiz.fsf_-_@lxoliva.fsfla.org |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1867448wrt; Wed, 28 Dec 2022 04:33:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXuyuatLfeu/LsIlBaczaay8VPB6JuOLi18lp1ejGbJ9k130FxIuyWkUDUvujVp4gJoPk4AD X-Received: by 2002:a17:906:a2d6:b0:7c0:bf7c:19f4 with SMTP id by22-20020a170906a2d600b007c0bf7c19f4mr20186536ejb.74.1672230832212; Wed, 28 Dec 2022 04:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672230832; cv=none; d=google.com; s=arc-20160816; b=FETPajfxJEoEgzLyY6qEhB2No6Q2yfN3ouyH8a8XLHidxUmEPBQIJWyj3iNimaym52 84u9/jqdYjc1EwyMtvTyxdMbf2gSQn3hbF1lHEWP0Ua13wkRH2zTQkDEE/Iw3hkQPQ4i /bThn/T1OnG6xZmEvC1OvN98m0TTA7C8+takulhVnDSbJTTfq5/bJpM1uycEw9XwHLCa IzSQZX8W/PS7rm1CwBXAfZ4/rMH+SMLHiC8Wf9/2aC4oPc3UhRUOsBiROmnyuaan2xKv OPfLnh9LoL1EWCd0FUYAU2/rzoPHEytQP/xSiV9WsTP3PNHo76Alh5pn302FMIcrWStL n+4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ManF7Tb7kpzpON2PUf0kBDZF9qXlXsJANibs3IpZkDg=; b=Iyxs77js90SmRUITaU9K0wH7VHTGQ8HbDbTnU5fbzMC3Oj+yIt2egEvD+fxq2KkVhv L3Hx1aZzB4yiuiJMAKwg+40USssmVLdYVsn5TVlROOub1QCEs5I29BQfhobkKkLLZfxq xvN6wfhYWUT6XmH1FssiIFx/8ckx1Xg/COz3PhlHwPk0WGo+vblug6zn1eqUU1NPrpVb IlcRF7VYfVWRUht+lFP905GRwn6wxr1OuzPhtNMbuixsdAgizgYaiKOmZbJWnCabpGw7 2mSOo8M9YVnpFy/Z7iJ5yoxzXYkJ+mHwIkECBDMipAJbvg6ts8thdh+W/1K6yQV/w1az LXag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MaESk8e7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id xi9-20020a170906dac900b007c4f75345e7si13147009ejb.458.2022.12.28.04.33.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 04:33:52 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=MaESk8e7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31D903858D35 for <ouuuleilei@gmail.com>; Wed, 28 Dec 2022 12:33:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31D903858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1672230831; bh=ManF7Tb7kpzpON2PUf0kBDZF9qXlXsJANibs3IpZkDg=; h=To:Cc:Subject:References:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=MaESk8e7jbqvMsTFD9emnrU+qnPksPOh9P5iVw6rBqcRxLqk2PjlTMCGc/Ff6AgPa WHrq4pbrSjW/7P9RWWCSxhd74xNzxuno+bVRiW74kZ1ibXRnzRmFeDGwTu/iJEqGAg s9y6P55IMn2m34PLWoYZcuxsHnadFqKiNdpKcOqg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 379033858D33 for <gcc-patches@gcc.gnu.org>; Wed, 28 Dec 2022 12:33:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 379033858D33 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 07903116316; Wed, 28 Dec 2022 07:33:00 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id KEJ2LGTJ+gFU; Wed, 28 Dec 2022 07:32:59 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id C8688116312; Wed, 28 Dec 2022 07:32:59 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2BSCWq86743588 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 28 Dec 2022 09:32:53 -0300 To: David Malcolm <dmalcolm@redhat.com> Cc: gcc-patches@gcc.gnu.org Subject: [15/17] prevent hash set/map insertion of deleted entries Organization: Free thinker, does not speak for AdaCore References: <or5ydxh4l4.fsf@lxoliva.fsfla.org> <orilhxe9z1.fsf@lxoliva.fsfla.org> <613b4501636146942775f23cfa8035f9eb7b84d3.camel@redhat.com> Date: Wed, 28 Dec 2022 09:32:52 -0300 In-Reply-To: <613b4501636146942775f23cfa8035f9eb7b84d3.camel@redhat.com> (David Malcolm's message of "Tue, 27 Dec 2022 12:53:18 -0500") Message-ID: <or5ydvemiz.fsf_-_@lxoliva.fsfla.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <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>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Alexandre Oliva via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Alexandre Oliva <oliva@adacore.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753461117474198492?= X-GMAIL-MSGID: =?utf-8?q?1753461117474198492?= |
Series |
[01/13] scoped tables: insert before further lookups
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Alexandre Oliva
Dec. 28, 2022, 12:32 p.m. UTC
On Dec 27, 2022, David Malcolm <dmalcolm@redhat.com> wrote: > Would it make sense to also add assertions that such entries aren't > Traits::is_deleted? (both for hash_map and hash_set) Yeah, I guess so. I've come up with something for hash-table proper too, coming up in 17/17. Just like the recently-added checks for empty entries, add checks for deleted entries as well. This didn't catch any problems, but it might prevent future accidents. Suggested by David Malcolm. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * hash-map.h (put, get_or_insert): Check that added entry doesn't look deleted either. & hash-set.h (add): Likewise. --- gcc/hash-map.h | 8 +++++--- gcc/hash-set.h | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-)
Comments
On 12/28/22 05:32, Alexandre Oliva via Gcc-patches wrote: > On Dec 27, 2022, David Malcolm <dmalcolm@redhat.com> wrote: > >> Would it make sense to also add assertions that such entries aren't >> Traits::is_deleted? (both for hash_map and hash_set) > > Yeah, I guess so. I've come up with something for hash-table proper > too, coming up in 17/17. > > > Just like the recently-added checks for empty entries, add checks for > deleted entries as well. This didn't catch any problems, but it might > prevent future accidents. Suggested by David Malcolm. > > Regstrapped on x86_64-linux-gnu. Ok to install? > > > for gcc/ChangeLog > > * hash-map.h (put, get_or_insert): Check that added entry > doesn't look deleted either. > & hash-set.h (add): Likewise. OK jeff
diff --git a/gcc/hash-map.h b/gcc/hash-map.h index 63fa21cf37c5b..e6ca9cf5e6429 100644 --- a/gcc/hash-map.h +++ b/gcc/hash-map.h @@ -173,8 +173,9 @@ public: if (ins) { e->m_key = k; - new ((void *) &e->m_value) Value (v); - gcc_checking_assert (!Traits::is_empty (*e)); + new ((void *)&e->m_value) Value (v); + gcc_checking_assert (!Traits::is_empty (*e) + && !Traits::is_deleted (*e)); } else e->m_value = v; @@ -204,7 +205,8 @@ public: { e->m_key = k; new ((void *)&e->m_value) Value (); - gcc_checking_assert (!Traits::is_empty (*e)); + gcc_checking_assert (!Traits::is_empty (*e) + && !Traits::is_deleted (*e)); } if (existed != NULL) diff --git a/gcc/hash-set.h b/gcc/hash-set.h index a98121a060eed..08e1851d5118d 100644 --- a/gcc/hash-set.h +++ b/gcc/hash-set.h @@ -61,7 +61,8 @@ public: { new (e) Key (k); // Catch attempts to insert e.g. a NULL pointer. - gcc_checking_assert (!Traits::is_empty (*e)); + gcc_checking_assert (!Traits::is_empty (*e) + && !Traits::is_deleted (*e)); } return existed;