public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@linux-m68k.org>
To: Szabolcs Nagy via Libc-alpha <libc-alpha@sourceware.org>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: Re: [PATCH v4] elf: Avoid deadlock between pthread_create and ctors [BZ #28357]
Date: Wed, 02 Feb 2022 15:31:51 +0100	[thread overview]
Message-ID: <87wnidjq5k.fsf@igel.home> (raw)
In-Reply-To: <20211001163326.3423517-1-szabolcs.nagy@arm.com> (Szabolcs Nagy via Libc-alpha's message of "Fri, 1 Oct 2021 17:33:26 +0100")

On Okt 01 2021, Szabolcs Nagy via Libc-alpha wrote:

> diff --git a/elf/dl-open.c b/elf/dl-open.c
> index 5295e931b0..6ea5dd2457 100644
> --- a/elf/dl-open.c
> +++ b/elf/dl-open.c
> @@ -66,6 +66,9 @@ struct dl_open_args
>       libc_map value in the namespace in case of a dlopen failure.  */
>    bool libc_already_loaded;
>  
> +  /* Set to true if the end of dl_open_worker_begin was reached.  */
> +  bool worker_continue;
> +
>    /* Original parameters to the program and the current environment.  */
>    int argc;
>    char **argv;
> @@ -482,7 +485,7 @@ call_dl_init (void *closure)
>  }
>  
>  static void
> -dl_open_worker (void *a)
> +dl_open_worker_begin (void *a)
>  {
>    struct dl_open_args *args = a;
>    const char *file = args->file;
> @@ -774,6 +777,36 @@ dl_open_worker (void *a)
>        _dl_call_libc_early_init (libc_map, false);
>      }
>  
> +  args->worker_continue = true;
> +}
> +
> +static void
> +dl_open_worker (void *a)
> +{
> +  struct dl_open_args *args = a;
> +
> +  args->worker_continue = false;
> +
> +  {
> +    /* Protects global and module specific TLS state.  */
> +    __rtld_lock_lock_recursive (GL(dl_load_tls_lock));
> +
> +    struct dl_exception ex;
> +    int err = _dl_catch_exception (&ex, dl_open_worker_begin, args);
> +
> +    __rtld_lock_unlock_recursive (GL(dl_load_tls_lock));
> +
> +    if (__glibc_unlikely (ex.errstring != NULL))
> +      /* Reraise the error.  */
> +      _dl_signal_exception (err, &ex, NULL);
> +  }
> +
> +  if (!args->worker_continue)
> +    return;

Why do you need worker_continue?  How can worker_continue not be set at
this point?

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

  parent reply	other threads:[~2022-02-02 14:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 16:33 Szabolcs Nagy
2021-10-01 16:43 ` Adhemerval Zanella
2021-10-04 13:00   ` Szabolcs Nagy
2022-02-02 14:31 ` Andreas Schwab [this message]
2022-02-02 14:41   ` Szabolcs Nagy
2022-02-02 15:13     ` Andreas Schwab
2022-02-02 15:17     ` Andreas Schwab

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=87wnidjq5k.fsf@igel.home \
    --to=schwab@linux-m68k.org \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /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).