You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fixup! trace2: collect Windows-specific process information
Guard against infinite loop while computing the parent process hierarchy.
CreateToolhelp32Snapshot() is used to get a list of all processes on the
system. Each process entry contains the process PID and PPID (alive at the
time of the snapshot). We compute the set of ancestors of the current process
by repeated searches on this list.
Testing revealed that the snapshot can contain PPID cycles. This causes an
infinite loop during the set construction and causes the git.exe command to
hang.
Testing found an instance where 3 processes were in a PPID cycle. The
snapshot implied that each of these processes was its own great-grandparent.
This should not be possible unless a PID was recycled and just happened to
match up.
For full disclosure, the Windows "System Idle Process" has PID and PPID 0.
If it were to launch a Git command, it could cause a similar infinite loop.
Or more properly, if any ancestor of the current Git command has PPID 0, it
will appear to be a descendant of the idle process and trigger the problem.
This commit fixes both cases by maintaining a list of the PIDs seen during
the ancestor walk and stopping if a cycle is detected.
Additionally, code was added to truncate the search after a reasonable fixed
depth limit.
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
0 commit comments