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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id EABF43836C15 for ; Wed, 25 Nov 2020 10:35:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EABF43836C15 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-kdffeaswPl6A__m8TG_rAQ-1; Wed, 25 Nov 2020 05:35:46 -0500 X-MC-Unique: kdffeaswPl6A__m8TG_rAQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9DB9218C89E3; Wed, 25 Nov 2020 10:35:45 +0000 (UTC) Received: from localhost (unknown [10.33.37.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A13D60C43; Wed, 25 Nov 2020 10:35:45 +0000 (UTC) Date: Wed, 25 Nov 2020 10:35:44 +0000 From: Jonathan Wakely To: "H.J. Lu" Cc: Andreas Schwab , trodgers@redhat.com, GCC Patches , libstdc++ Subject: Re: [PATCH] libstdc++: Add C++2a synchronization support Message-ID: <20201125103544.GG1312820@redhat.com> References: <20201023102859.GA1525304@redhat.com> <20201026214827.3530995-1-rodgert@appliantology.com> <87a6va3fl3.fsf@igel.home> <20201121170450.GN1312820@redhat.com> <20201121173931.GO1312820@redhat.com> <20201124234521.GD1312820@redhat.com> <20201125010711.GE1312820@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201125010711.GE1312820@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 10:35:52 -0000 On 25/11/20 01:07 +0000, Jonathan Wakely wrote: >On 24/11/20 23:45 +0000, Jonathan Wakely wrote: >>On 21/11/20 16:36 -0800, H.J. Lu wrote: >>>On Sat, Nov 21, 2020 at 9:40 AM Jonathan Wakely via Gcc-patches >>> wrote: >>>> >>>>On 21/11/20 17:04 +0000, Jonathan Wakely wrote: >>>>>On 21/11/20 16:16 +0100, Andreas Schwab wrote: >>>>>>In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, >>>>>> from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: >>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h: In member function 'void std::atomic_flag::wait(bool, std::memory_order) const': >>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:239: error: no matching function for call to '__atomic_wait(const __atomic_flag_data_type*, bool&, std::atomic_flag::wait(bool, std::memory_order) const::)' >>>>>>In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:41, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, >>>>>> from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: >>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_wait.h:265: note: candidate: 'template void std::__atomic_wait(const _Tp*, _Tp, _Pred)' >>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_wait.h:265: note: template argument deduction/substitution failed: >>>>>>In file included from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/shared_ptr_atomic.h:33, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/memory:78, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/stdc++.h:82, >>>>>> from /daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/m68k-linux/bits/extc++.h:32, >>>>>> from /daten/aranym/gcc/gcc-20201121/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc:37: >>>>>>/daten/aranym/gcc/gcc-20201121/Build/m68k-linux/libstdc++-v3/include/bits/atomic_base.h:239: note: deduced conflicting types for parameter '_Tp' ('unsigned char' and 'bool') >>>>> >>>>>I'm testing this. >>>> >>>>I'm committing this instead, it's the same but also disables >>>>29_atomics/atomic/wait_notify/generic.cc on non-linux targets. >>>> >>>>Tested sparc-solaris2.11 and powerpc64le-linux. >>>> >>>>There are still some timeouts on linux: >>>> >>>>FAIL: 30_threads/latch/3.cc execution test >>>>FAIL: 30_threads/semaphore/try_acquire_for.cc execution test >>>> >>> >>>I opened: >>> >>>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97936 >> >>I've disabled the failing tests for now. They can be re-enabled after >>the problem is found and fixed. > >I was finally able to reproduce the hangs, and I think this is the >fix: > >--- a/libstdc++-v3/include/bits/atomic_wait.h >+++ b/libstdc++-v3/include/bits/atomic_wait.h >@@ -100,9 +100,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > auto __e = syscall (SYS_futex, static_cast(__addr), > static_cast(__futex_wait_flags::__wait_private), > __val, nullptr); >- if (!__e) >+ if (!__e || errno == EAGAIN) > break; >- else if (!(errno == EINTR || errno == EAGAIN)) >+ else if (errno != EINTR) > __throw_system_error(__e); > } > } > >The problem is that we're going into a busy loop when SYS_futex >returns EAGAIN, but that means the current value doesn't match the >expected value, so we should return not keep waiting for the value to >change. I've pushed that as ad9cbcee543ecccd79fa49dafcd925532d2ce210 but there are still other FAILs to be fixed.