From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id 0C8803858D33; Mon, 21 Aug 2023 21:26:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C8803858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso500392366b.1; Mon, 21 Aug 2023 14:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692653186; x=1693257986; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6npdrv0pKvZKlqDn987Hi+R7guNmRC9pNMD83JVR3ic=; b=HzlQqMfQipqexNO5e7s01Bj5iliSkPC3XLCndX/HXuVPb+K3EQhuArsSsb1FCmxcsu IUX4nhQKowbL01CzQH7Vy2JNjhsVWhu+VkK+vQ/V2vsZA7LjoPj/RwPZA3z7YAjukUlr QCH9ER9sfFbN2kJ0S2nxPT3aAL3QOYPbKS+QnAyIR5getq6ndtfLItwYwkirfUdkk6Ko hFCOvkYa1pMQDRQ9yd50VtRrm9JKmsBQWwF6KKLGV0Ddf2meUdCaDiisGHPSctYMSWgs YvXkrO32kw5X+b6upoeyOSJMZB42dr/UhF6wXuqFygI8q+BnofmJd5UjzymdYJHa45AK m41A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692653186; x=1693257986; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6npdrv0pKvZKlqDn987Hi+R7guNmRC9pNMD83JVR3ic=; b=jzCmDxCI+0A2/2QDArr8bly0vC8IzM1UnPi04N5eUv2nYU9faIXKttSZawF3IM1D5G zAoK6VogQmutrybuvpCZG71rOx2HYWiAqiiRdEqUYmAAfz4ZvmvYMkYBpLQsgzE4LGjC 9CZ3k+WvSv2ZeFPAjot5yX62bUXB5GW2vTYp2Xxl0Mjc+dKML6SEAmwYnzrLTzxRqYsw fFPsmX26cECVRzp/YNjVORBLkTP0fsiwVulduePXKZD2HjJWOV6MY3PJk9v9kwhBXRCl TcOCR2YwQCK0YMxZz68zJkkWTOiusktX2f7kHIvicNBb6ckEzMFrybMLmIr54Bhx7q9V Dm+g== X-Gm-Message-State: AOJu0YzJXIFGdHStw9oSKESIXkPPD4T7IQ843guwmidxPidCxSRSqcBo dpOqKYUg5iteBytuYC6Wib8nMoYz8HgdnxC6Tu4= X-Google-Smtp-Source: AGHT+IHRPyk9IhzkgngMdeeoiZ/pomx2yc+/0FxkE34cBEaNVrkV5Z592OMeDg7dWGPYXDv//DD3Eub4y/tPbUDOl9Q= X-Received: by 2002:a17:906:74cf:b0:992:9ea0:2317 with SMTP id z15-20020a17090674cf00b009929ea02317mr6570089ejl.61.1692653186382; Mon, 21 Aug 2023 14:26:26 -0700 (PDT) MIME-Version: 1.0 References: <70988952-dab7-3ba6-4694-2d90c035f80f@gmail.com> In-Reply-To: From: Jonathan Wakely Date: Mon, 21 Aug 2023 22:26:15 +0100 Message-ID: Subject: Re: [PATCH] Fix tests sensitive to internal library allocations To: =?UTF-8?Q?Fran=C3=A7ois_Dumont?= Cc: "libstdc++" , gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 List-Id: On Mon, 21 Aug 2023 at 21:20, Fran=C3=A7ois Dumont w= rote: > > Here is the updated and tested patch. OK for trunk, thanks. We could consider it for the branches too (I'm going to remove the global strings on the gcc-13 branch tomorrow). > > On 21/08/2023 20:07, Jonathan Wakely wrote: > > On Mon, 21 Aug 2023 at 18:05, Fran=C3=A7ois Dumont via Libstdc++ > > wrote: > >> Hi > >> > >> Here is a propocal to fix tests sensitive to libstdc++ internal alloca= tions. > > Surely the enter() and exit() calls should be a constructor and destruc= tor? > > > > The constructor could use count() to get the count, and then restore > > it in the destructor. Something like: > > > > --- a/libstdc++-v3/testsuite/util/replacement_memory_operators.h > > +++ b/libstdc++-v3/testsuite/util/replacement_memory_operators.h > > @@ -75,12 +75,30 @@ namespace __gnu_test > > counter& cntr =3D get(); > > cntr._M_increments =3D cntr._M_decrements =3D 0; > > } > > + > > + struct scope > > + { > > + scope() : _M_count(counter::count()) { } > > + ~scope() { counter::get()._M_count =3D _M_count; } > > + > > + private: > > + std::size_t _M_count; > > + > > +#if __cplusplus >=3D 201103L > > + scope(const scope&) =3D delete; > > + scope& operator=3D(const scope&) =3D delete; > > +#else > > + scope(const scope&); > > + scope& operator=3D(const scope&); > > +#endif > > + }; > > }; > > > > template > > bool > > check_new(Alloc a =3D Alloc()) > > { > > + __gnu_test::counter::scope s; > > __gnu_test::counter::exceptions(false); > > __gnu_test::counter::reset(); > > (void) a.allocate(10); > > > > > > > > > > > > > >> Tested by restoring allocation in tzdb.cc. > >> > >> As announced I'm also adding a test to detect such allocations. If it = is > >> ok let me know if you prefer to see it in a different place. > > The test is a good idea. I think 17_intro/no_library_allocation.cc > > would be a better place for it. > > > >> libstdc++: Fix tests relying on operator new/delete overload > >> > >> Fix tests that are checking for an allocation plan. They are fai= ling if > >> an allocation is taking place outside the test. > >> > >> libstdc++-v3/ChangeLog > >> > >> * testsuite/util/replacement_memory_operators.h > >> (counter::_M_pre_enter_count): New. > >> (counter::enter, counter::exit): New static methods to c= all > >> on main() enter/exit. > >> * testsuite/23_containers/unordered_map/96088.cc (main): > >> Call __gnu_test::counter::enter/exit. > >> * testsuite/23_containers/unordered_multimap/96088.cc > >> (main): Likewise. > >> * testsuite/23_containers/unordered_multiset/96088.cc > >> (main): Likewise. > >> * testsuite/23_containers/unordered_set/96088.cc (main): > >> Likewise. > >> * testsuite/ext/malloc_allocator/deallocate_local.cc > >> (main): Likewise. > >> * testsuite/ext/new_allocator/deallocate_local.cc (main)= : > >> Likewise. > >> * testsuite/ext/throw_allocator/deallocate_local.cc (mai= n): > >> Likewise. > >> * testsuite/ext/pool_allocator/allocate_chunk.cc (starte= d): > >> New global. > >> (operator new(size_t)): Check started. > >> (main): Set/Unset started. > >> * testsuite/ext/no_library_allocation.cc: New test case. > >> > >> Ok to commit ? > >> > >> Fran=C3=A7ois