From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 9EB3D3858C2F for ; Mon, 30 Jan 2023 15:15:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EB3D3858C2F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca Received: from [172.16.0.192] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 31DDF1E112; Mon, 30 Jan 2023 10:15:46 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1675091746; bh=xh1pRa0JC4V801S+BOmQ3FihVObU8wT2ehyT6ebKENU=; h=Date:Subject:To:References:From:In-Reply-To:From; b=SZvrCo3ooz2IFTGhd6fdOn4D5fjFkKvAdYDNHJ5/k93oioQfnF5XtOIgpeChuG05P h7AacArfMG9uVQdJ9YUhLisdmJLjnSA6s+0lJkXWTGT9KHXIxfhSffFzLqIE8ircHo 0x0V+WmkR/ioxcoYOXJD4v2waXQA2YJo/Lqe6Qts= Message-ID: <5ebb2d7e-392f-af15-5d85-8837d3febb68@simark.ca> Date: Mon, 30 Jan 2023 10:15:45 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v2] Fix comparator bug in cooked index Content-Language: fr To: Tom Tromey , gdb-patches@sourceware.org References: <20230130145617.1619439-1-tromey@adacore.com> From: Simon Marchi In-Reply-To: <20230130145617.1619439-1-tromey@adacore.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,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 List-Id: On 1/30/23 09:56, Tom Tromey via Gdb-patches wrote: > Simon pointed out that the cooked index template-matching patch > introduced a failure in libstdc++ debug mode. In particular, the new > code violates the assumption of std::lower_bound and std::upper_bound > that the range is sorted with respect to the comparison. > > When I first debugged this, I thought the problem was unfixable as-is > and that a second layer of filtering would have to be done. However, > on irc, Simon pointed out that it could perhaps be solved if the > comparison function were assured that one operand always came from the > index, with the other always being the search string. > > This patch implements this idea. > > First, a new mode is introduced: a sorting mode for > cooked_index_entry::compare. In this mode, strings are compared > case-insensitively, but we're careful to always sort '<' before any > other printable character. This way, two names like "func" and > "func" will be sorted next to each other -- i.e., "func1" will > not be seen between them. This is important when searching. > > Second, the compare function is changed to work in a strcmp-like way. > This makes it easier to test and (IMO) understand. > > Third, the compare function is modified so that in non-sorting modes, > the index entry is always the first argument. This allows consistency > in compares. > > I regression tested this in libstdc++ debug mode on x86-64 Fedora 36. > It fixes the crash that Simon saw. > > This is v2. I believe it addresses the review comments, except for > the 'enum class' change, as I mentioned in email on the list. This LGTM: Approved-By: Simon Marchi Simon