testsuite: tolerate compare_exchange_weak spurious failure
Andrew Pinski
andrew.pinski@oss.qualcomm.com
Wed Mar 11 06:01:37 GMT 2026
On Tue, Mar 10, 2026 at 10:30 PM Alexandre Oliva <oliva@adacore.com> wrote:
>
>
> compare_exchange_weak is allowed to fail spuriously, and we're
> actually hitting such spurious failures quite often on ppc-vx7r2,
> presumably when random interrupts hit between ll and sc.
>
> Tolerate one such failure, hopefully that will suffice.
>
> Regstrapped on x86_64-linux-gnu, also tested with gcc-15 for ppc-vx7r2.
> Ok to install?
LGTM.
I am also worried that 2 weak compare exchanges would not be enough
and still cause a spurious failure
but at least it is easier to understand based on the comment there.
Thanks,
Andrew
>
>
> for libstdc++-v3/ChangeLog
>
> * testsuite/29_atomics/atomic/compare_exchange_padding.cc:
> Tolerate one compare_exchange_weak spurious failure.
> ---
> .../29_atomics/atomic/compare_exchange_padding.cc | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
> index d9c7b90c1a5c1..3fc2f6b4f8031 100644
> --- a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
> +++ b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc
> @@ -37,8 +37,8 @@ main ()
> fill_struct(n);
> n.c = 'b';
> n.s = 71;
> - // padding cleared on compexchg
> - VERIFY( as.compare_exchange_weak(s, n) );
> + // padding cleared on compexchg. tolerate one spurious _weak failure.
> + VERIFY( as.compare_exchange_weak(s, n) || as.compare_exchange_weak(s, n) );
> VERIFY( as.compare_exchange_strong(n, s) );
> return 0;
> }
>
> --
> Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/
> Free Software Activist FSFLA co-founder GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity.
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive!
More information about the Libstdc++
mailing list