public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-95989-4-b3o900utUI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95989-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95989

--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #13)
> I'm testing this:
> 
> 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.27,
but that's OK).

> +  /* See PR libstdc++/95989  */
> +  return pthread_self ();
> +#else
>    return __gthrw_(pthread_self) ();
> +#endif
>  }
>  
>  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 inline
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 another
could inline the version returning thread::id(__gthread_self()). This could
result in two different IDs for the main thread of a single-threaded program.
So maybe we should just stick to returning thread::id(1) for all glibc
versions.

  parent reply	other threads:[~2020-07-09  9:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 20:25 [Bug libstdc++/95989] New: " webrown.cpp at gmail dot com
2020-06-30 22:35 ` [Bug libstdc++/95989] " redi at gcc dot gnu.org
2020-06-30 22:59 ` antal.buss at ualberta dot ca
2020-06-30 23:21 ` redi at gcc dot gnu.org
2020-06-30 23:30 ` redi at gcc dot gnu.org
2020-06-30 23:39 ` redi at gcc dot gnu.org
2020-07-01 10:15 ` redi at gcc dot gnu.org
2020-07-01 13:28 ` fw at gcc dot gnu.org
2020-07-01 13:53 ` redi at gcc dot gnu.org
2020-07-06 12:38 ` fw at gcc dot gnu.org
2020-07-08 14:39 ` redi at gcc dot gnu.org
2020-07-08 15:36 ` redi at gcc dot gnu.org
2020-07-09  9:58 ` redi at gcc dot gnu.org [this message]
2020-11-11 17:26 ` redi at gcc dot gnu.org
2020-11-19 21:07 ` cvs-commit at gcc dot gnu.org
2020-11-20 13:49 ` cvs-commit at gcc dot gnu.org
2020-11-20 13:52 ` redi at gcc dot gnu.org
2021-09-21 13:42 ` ebotcazou at gcc dot gnu.org
2022-03-04  4:08 ` lightningdzeyenr at gmail dot com
2022-03-04  9:25 ` redi at gcc dot gnu.org
2022-03-09  4:27 ` lightningdzeyenr at gmail dot com
2023-03-03 19:10 ` cvs-commit at gcc dot gnu.org
2024-04-10 12:56 ` redi at gcc dot gnu.org
2024-04-10 17:32 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95989-4-b3o900utUI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).