From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B8A1F3853831 for ; Mon, 31 Oct 2022 15:37:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B8A1F3853831 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667230679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gj3+oi2JHpuTlQcPMiJIUuyDi4ovR5YzQVruIIQUhd4=; b=DuB2EDOJ15t0ZXM9DRtLpJJbKjvjW3SzBnxAJv44yjWBDNp36kWAzKfZ8FTDLvrR2WACPz fBcsb9TFYeNFyWWhB7jZ5aT1m+czprm6egcARK1YRM2Jp8TCGCXydckGENQCj3zi3tFuSI ePcrL4CdlJ8lRenj4Uy8eaI+yIPLOVk= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-573-mkstzreJOY-6r54MoTE1eg-1; Mon, 31 Oct 2022 11:37:57 -0400 X-MC-Unique: mkstzreJOY-6r54MoTE1eg-1 Received: by mail-ed1-f71.google.com with SMTP id f20-20020a0564021e9400b00461ea0ce17cso8103863edf.16 for ; Mon, 31 Oct 2022 08:37:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=gj3+oi2JHpuTlQcPMiJIUuyDi4ovR5YzQVruIIQUhd4=; b=o4d76h4q0mcxY6L9bsbO9zHy4uYs67O3G4HtrcmnY/7opZhFYINKJ2dTEQ1PiLkyRt +DpRrrbIvFo02dlIP47Q9K7ocY0ZhxkdbYiaETMKUPyFfOJxdXbmJEIgX0Id91lvfjl8 0x+XZqvxl/zKn1+0A9FkTARj/XnzdVu0jiVFsMax57Y3Dyqa1Ts4Z5syWCX7clcvbfUr Q1FJSNMiaoC/bRW7/IzJcx2SF9EImZL9kYB7KUGQlcEhwuHvUuJnk7w3nLzvLYKRiFra ZYMUbadyeNrmFtTxf27EWrTpCZrAGrQ8Bwr+ngbzSL9fbOrqOkw9wpwzEs4XLrDRb6bt nzPg== X-Gm-Message-State: ACrzQf0IXMzthh/kqVL/oFA2nel9kYES6u5DSuTq5z6kIwEHZTaGPV7i frlDKkaGw0HVClwZFxI7I7IOHZKUsdFASt+26UYGqH+DdNRg4BXEEJiL3kbNN4gbMsJbD89mkcb crtaQqc+x38ir5TTq7AfnyGCmkRU81nI= X-Received: by 2002:a17:906:cc58:b0:7a9:6b4e:79e4 with SMTP id mm24-20020a170906cc5800b007a96b4e79e4mr13148468ejb.57.1667230676739; Mon, 31 Oct 2022 08:37:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6+AHEHKM5sdKE8BGJP6DGWi2Wbxfq/1vBEn3zzQ+bajkQ2bvspZgM0CDHPo3sjsCNltp012lJewTSW/YlNW0w= X-Received: by 2002:a17:906:cc58:b0:7a9:6b4e:79e4 with SMTP id mm24-20020a170906cc5800b007a96b4e79e4mr13148443ejb.57.1667230676541; Mon, 31 Oct 2022 08:37:56 -0700 (PDT) MIME-Version: 1.0 References: <20220916202127.579816-1-jwakely@redhat.com> <5772422.MhkbZ0Pkbq@fomalhaut> In-Reply-To: <5772422.MhkbZ0Pkbq@fomalhaut> From: Jonathan Wakely Date: Mon, 31 Oct 2022 15:37:45 +0000 Message-ID: Subject: Re: [committed] libstdc++: Fix compare_exchange_padding.cc test for std::atomic_ref To: Eric Botcazou Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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, 31 Oct 2022 at 15:34, Eric Botcazou wrote: > > > The test was only failing for me with -m32 (and not -m64), so I didn't > > notice until now. That probably means we should make the test fail more > > reliably if the padding isn't being cleared. > > The tests fail randomly for me on SPARC64/Linux: > > FAIL: 29_atomics/atomic/compare_exchange_padding.cc execution test > FAIL: 29_atomics/atomic_ref/compare_exchange_padding.cc execution test > > /home/ebotcazou/src/libstdc++-v3/testsuite/29_atomics/atomic_ref/ > compare_exchange_padding.cc:34: int main(): Assertion 'compare_struct(ts, es)' > failed. > FAIL: 29_atomics/atomic_ref/compare_exchange_padding.cc execution test > > std::atomic as{ s }; > auto ts = as.load(); > VERIFY( !compare_struct(s, ts) ); // padding cleared on construction > as.exchange(s); > auto es = as.load(); > VERIFY( compare_struct(ts, es) ); // padding cleared on exchange > > How is it supposed to pass exactly? AFAICS you have no control on the padding > bits of ts or es and, indeed, at -O2 the loads are scalarized: > > __buf$c_81 = MEM[(struct S *)&__buf].c; > __buf$s_59 = MEM[(struct S *)&__buf].s; > __buf ={v} {CLOBBER(eol)}; > ts.c = __buf$c_81; > ts.s = __buf$s_59; > [...] > __buf$c_100 = MEM[(struct S *)&__buf].c; > __buf$s_35 = MEM[(struct S *)&__buf].s; > __buf ={v} {CLOBBER(eol)}; > es.c = __buf$c_100; > es.s = __buf$s_35; > _66 = MEM [(char * {ref-all})&ts]; > _101 = MEM [(char * {ref-all})&es]; > if (_66 != _101) > goto ; [0.04%] > else > goto ; [99.96%] > > so the result of the 4-byte comparison is random. I suppose we could use memcmp on the as variable itself, to inspect the actual stored padding rather than the returned copy of it.