From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 69594384A40A; Thu, 9 Jul 2020 09:58:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69594384A40A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594288706; bh=eg8sHYmBm2TxUo6WMkO3PeBhQD/YbNFMGhVEPLEh4z0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XqgF+z5YeKf5AC36SCLewUcYJPKxxbj9TK8IVwlpEOXbjE2qZOcTKQ8+4qr4sFqsm R2mb3xfH6ep/eYrDGa/ztfcoZ9WjZ+McxgpUSQo1Meq6hPaJUPwlMqw/sQ5hqUaxFB wGVFoJGNFqLT3T8aNyRPej7RGHlCJ6dN/m75LCVA= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/95989] Segmentation fault compiling with static libraries and using jthread::request_stop Date: Thu, 09 Jul 2020 09:58:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jul 2020 09:58:26 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95989 --- Comment #14 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #13) > I'm testing this: >=20 > diff --git a/libgcc/gthr-posix.h b/libgcc/gthr-posix.h > index 965247602ac..0af84a781e5 100644 > --- a/libgcc/gthr-posix.h > +++ b/libgcc/gthr-posix.h > @@ -684,7 +684,12 @@ __gthread_equal (__gthread_t __t1, __gthread_t __t2) > static inline __gthread_t > __gthread_self (void) > { > +#if __GLIBC_PREREQ(2, 27) Hmm, maybe we should just check #ifdef __GLIBC__ here, since it's available= in libc even before glibc 2.27 (it returns 0 rather than a real tid before 2.2= 7, but that's OK). > + /* See PR libstdc++/95989 */ > + return pthread_self (); > +#else > return __gthrw_(pthread_self) (); > +#endif > } >=20=20 > static inline int > diff --git a/libstdc++-v3/include/std/thread > b/libstdc++-v3/include/std/thread > index 0445ab1e319..2772dd3950e 100644 > --- a/libstdc++-v3/include/std/thread > +++ b/libstdc++-v3/include/std/thread > @@ -364,13 +364,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > inline thread::id > get_id() noexcept > { > -#ifdef __GLIBC__ > +#if defined __GLIBC__ && ! __GLIBC_PREREQ(2, 27) And maybe we shouldn't change this check either. If we make it depend on the glibc version then because this function is inl= ine a program could have two different definitions inlined if different objects were compiled by different versions of gcc, or against different versions of glibc. One object could inline the version returning thread::id(1) and anot= her could inline the version returning thread::id(__gthread_self()). This could result in two different IDs for the main thread of a single-threaded progra= m. So maybe we should just stick to returning thread::id(1) for all glibc versions.=