mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alexey Izbyshev <>
Subject: Re: [musl] [PATCH] set tid address in fork
Date: Thu, 20 Jul 2023 17:22:07 +0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On 2023-07-20 16:53, changdiankang wrote:
> In pthrad_exit the exiting thread will hold the thread list lock,
> and will unlock it in kernel by clear the tid address 
> &__thread_list_lock.
> A thread created by pthrad_create is created with clone syscall with
> CLONE_CHILD_CLEARTID flag and &__thread_list_lock as child_tid
> parameter. When the thread exits, the thread list lock can be woke up
> (see man clone CLONE_CHILD_CLEARTID).
> But in fork, the main thread is created with fork syscall or with
> clone syscall without CLONE_CHILD_CLEARTID flag. The 
> &__thread_list_lock
> is not be set to tid address. So when the main thread exits, the thread
> list lock can't be woke up by kernel. This may lead some problems when
> other child threads try to hold this lock. For example, a child thread
> blocks at waiting thread list lock when joining the main thread.
> To fix this issue, we should set &__thread_list_lock to the main thread 
> tid
> address in fork.

This bug has already been discovered, see


  reply	other threads:[~2023-07-20 14:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 13:53 changdiankang
2023-07-20 14:22 ` Alexey Izbyshev [this message]
2023-07-20 17:30   ` Rich Felker

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:

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

  git send-email \ \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

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 NNTP newsgroup(s).