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.133.124]) by sourceware.org (Postfix) with ESMTPS id AEEFD3858C2D for ; Fri, 1 Sep 2023 15:22:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEEFD3858C2D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-a7x_J_SrPUSp1jwy65egeQ-1; Fri, 01 Sep 2023 11:22:11 -0400 X-MC-Unique: a7x_J_SrPUSp1jwy65egeQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2bcbb224910so27200551fa.0 for ; Fri, 01 Sep 2023 08:22:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693581729; x=1694186529; 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=+/sZaQStyPDt+ykm9F5uNySJfgYLjeufSriX9Ii7E5E=; b=h6Jr9Kj/vp5+h8XF0QWdbsx/vRA+jWzkUVYkeTKzeNm8FZMYNs9hkxG62EfU7tQbgQ MHioqbptmyGqOvGea5+X8fClaEL6zrZNRtLceYclwh5YJiVRaoK2pUZ1kkTKE8n3QggN dY15j17GFk/z5CXpQnmYieuxZC/fp/9F0JPUpTXMssnDRI5W/FiJh1ppFZ9E84IDR9L2 a1NIPYSmCIqBuPa+h0j7NkeT3IcAvXZlCXSfMNLcpc3U0qRJWbziyJVO0XV//afUN8lb OVSax2PxSdS53EobIzDMR+IHcTGRCSzWHzsmUEwJqcE1UxCyx5l9zvX0wCyQMURs5pAp 4yHg== X-Gm-Message-State: AOJu0YzrT+1sm1DSKVrtuUEAK18CwcVbxqcUcPYAAYPPYRu4NASkBHKX ldUJ2UyFAK2HYdmtRkXRaLD3UwFsZLHwDfA+5+MNmaEZhe5T178vhb//gSSds0nCw/7XHVsR9ex J6UbRg+hZ++7gAM9MgpHV8X+6Ta2eG08qkAti3tw= X-Received: by 2002:a2e:9086:0:b0:2bc:d993:bdaa with SMTP id l6-20020a2e9086000000b002bcd993bdaamr2198180ljg.18.1693581729737; Fri, 01 Sep 2023 08:22:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFu+HrPk63bFkhKD5VZilQ7Ui+JZtYy292FyN8/3PYQg49TKF+DNww9VHNtOD/Sn5FZ3fbqC6vtrxPFPfU4Gvk= X-Received: by 2002:a2e:9086:0:b0:2bc:d993:bdaa with SMTP id l6-20020a2e9086000000b002bcd993bdaamr2198157ljg.18.1693581729368; Fri, 01 Sep 2023 08:22:09 -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: Fri, 1 Sep 2023 16:21:58 +0100 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=-39.2 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no 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. This should be fixed now. I rewrote the test to check the padding byte directly, instead of inspecting a copy of it which might not preserve the padding bits.