* [PATCH] support: Add check for TID zero in support_wait_for_thread_exit
@ 2021-09-30 12:06 Florian Weimer
2021-10-01 15:27 ` Carlos O'Donell
0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2021-09-30 12:06 UTC (permalink / raw)
To: libc-alpha
Some kernel versions (observed with kernel 5.14 and earlier) can list
"0" entries in /proc/self/task. This happens when a thread exits
while the task list is being constructed. Treat this entry as not
present, like the proposed kernel patch does:
[PATCH] procfs: Do not list TID 0 in /proc/<pid>/task
<https://lore.kernel.org/all/8735pn5dx7.fsf@oldenburg.str.redhat.com/>
---
support/support_wait_for_thread_exit.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/support/support_wait_for_thread_exit.c b/support/support_wait_for_thread_exit.c
index 658a813810..5e3be421a7 100644
--- a/support/support_wait_for_thread_exit.c
+++ b/support/support_wait_for_thread_exit.c
@@ -43,7 +43,10 @@ support_wait_for_thread_exit (void)
return;
}
- if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0)
+ /* In some kernels, "0" entries denote a thread that has just
+ exited. */
+ if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0
+ || strcmp (e->d_name, "0") == 0)
continue;
int task_tid = atoi (e->d_name);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] support: Add check for TID zero in support_wait_for_thread_exit
2021-09-30 12:06 [PATCH] support: Add check for TID zero in support_wait_for_thread_exit Florian Weimer
@ 2021-10-01 15:27 ` Carlos O'Donell
0 siblings, 0 replies; 2+ messages in thread
From: Carlos O'Donell @ 2021-10-01 15:27 UTC (permalink / raw)
To: Florian Weimer, libc-alpha
On 9/30/21 08:06, Florian Weimer via Libc-alpha wrote:
> Some kernel versions (observed with kernel 5.14 and earlier) can list
> "0" entries in /proc/self/task. This happens when a thread exits
> while the task list is being constructed. Treat this entry as not
> present, like the proposed kernel patch does:
>
> [PATCH] procfs: Do not list TID 0 in /proc/<pid>/task
> <https://lore.kernel.org/all/8735pn5dx7.fsf@oldenburg.str.redhat.com/>
Upstream kernel patch has been ack by Christian Brauner.
Testing looks good on x86_64 and i686. Patchwork CI/CD is clean 2/2.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
> ---
> support/support_wait_for_thread_exit.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/support/support_wait_for_thread_exit.c b/support/support_wait_for_thread_exit.c
> index 658a813810..5e3be421a7 100644
> --- a/support/support_wait_for_thread_exit.c
> +++ b/support/support_wait_for_thread_exit.c
> @@ -43,7 +43,10 @@ support_wait_for_thread_exit (void)
> return;
> }
>
> - if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0)
> + /* In some kernels, "0" entries denote a thread that has just
> + exited. */
> + if (strcmp (e->d_name, ".") == 0 || strcmp (e->d_name, "..") == 0
> + || strcmp (e->d_name, "0") == 0)
OK. Skip "0" entry.
> continue;
>
> int task_tid = atoi (e->d_name);
>
--
Cheers,
Carlos.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-01 15:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 12:06 [PATCH] support: Add check for TID zero in support_wait_for_thread_exit Florian Weimer
2021-10-01 15:27 ` Carlos O'Donell
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).