HomeFreeBSD

libprocstat kstack: fix race with thread creation

Description

libprocstat kstack: fix race with thread creation

When collecting kernel stacks for a target process, if the process
adds a thread between the two calls to sysctl, ignore the additional
threads. Previously, procstat would print only a useless error
message. Now, it prints a consistent snapshot of the stacks.
We know that snapshot is already stale, but it could still be stale
even with a more complex fix to reallocate and retry, so such a fix
is hardly worth the effort.

Reported by: Daniel.Mitchell@emc.com
MFC after: 1 week
Sponsored by: Dell EMC Isilon

(cherry picked from commit 427f12f150e875c40acb84f292a80bfa0b90a1a2)

Details

Provenance
vangyzenAuthored on May 27 2021, 4:33 PM
Parents
rG94df301ac27e: Wait longer for a previous IPI to be sent
Branches
Unknown
Tags
Unknown