Message ID | 878rze4690.fsf@oldenburg.str.redhat.com |
---|---|
State | New |
Headers | show |
Series | support: Add check for TID zero in support_wait_for_thread_exit | expand |
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); >
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);