From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by sourceware.org (Postfix) with ESMTPS id 8C1C63852753 for ; Thu, 9 Jun 2022 16:14:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8C1C63852753 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by mail.gandi.net (Postfix) with ESMTPSA id AEFB0C0010; Thu, 9 Jun 2022 16:14:46 +0000 (UTC) Received: by localhost (Postfix, from userid 1000) id C8C855800FC; Thu, 9 Jun 2022 18:14:45 +0200 (CEST) From: Dodji Seketeli To: Giuliano Procida Cc: libabigail@sourceware.org, kernel-team@android.com, maennich@google.com Subject: Re: [PATCH v2] limit repeated DIE comparisons Organization: Me, myself and I References: <20220609110627.1469252-1-gprocida@google.com> <20220609111735.1488817-1-gprocida@google.com> X-Operating-System: Fedora 37 X-URL: http://www.seketeli.net/~dodji Date: Thu, 09 Jun 2022 18:14:45 +0200 In-Reply-To: <20220609111735.1488817-1-gprocida@google.com> (Giuliano Procida's message of "Thu, 9 Jun 2022 12:17:35 +0100") Message-ID: <8735gdlsp6.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jun 2022 16:14:51 -0000 Hello, Giuliano Procida a =C3=A9crit: I have applied the patch, thanks a lot for it! I just have one useless comment below, for my own understanding. > Exponential explosion of DIE comparison has been possible since the > limit of at most 5 pending struct/union DIE comparison pairs was > lifted. > > This commit adds two things to control this (with a negligible chance of > falsely finding that two DIEs are equivalent when they are not). > > - DIE self-comparisons immediately return true > - once a DIE pair has been compared 10000 times, always return true > > * src/abg-dwarf-reader.cc (read_context): Add mutable > die_comparison_visits_ member. > (compare_dies): Return true if this is a self-comparison. > Return true if we have visited this comparison 10000 times. > > Signed-off-by: Giuliano Procida > --- > src/abg-dwarf-reader.cc | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc > index 7bf2375d..27dd4faf 100644 > --- a/src/abg-dwarf-reader.cc > +++ b/src/abg-dwarf-reader.cc > @@ -2094,6 +2094,9 @@ public: > /// A map that associates a function type representations to > /// function types, inside a translation unit. > mutable istring_fn_type_map_type per_tu_repr_to_fn_type_maps_; > + mutable std::unordered_map, > + size_t, > + dwarf_offset_pair_hash> die_comparison_visits_; >=20=20 > die_class_or_union_map_type die_wip_classes_map_; > die_class_or_union_map_type alternate_die_wip_classes_map_; > @@ -10216,6 +10219,15 @@ compare_dies(const read_context& ctxt, >=20=20 > Dwarf_Off l_offset =3D dwarf_dieoffset(const_cast(l)), > r_offset =3D dwarf_dieoffset(const_cast(r)); > + > + if (l_offset =3D=3D r_offset) > + return true; > + auto& visit =3D ctxt.die_comparison_visits_[std::make_pair(l_offset, r= _offset)]; > + if (visit =3D=3D 10000) > + return true; Interesting. I'll play with this and see what happens when we hit this. I hope I'll find a binary in the testsuite that hits this line, so that I can understand why the type is compared so many times. Thanks a lot! [...] Cheers, --=20 Dodji