Description

Licensee reports buffer deadlock issue in System/BuildHostPlatform.cs (lines 283-329). Moving Proc.WaitForExit() to after the for-loop seems to resolve the issue for them.

 public override ProcessInfo[] GetProcesses()
                {
                        List<ProcessInfo> Result = new List<ProcessInfo>();
 
                        ProcessStartInfo StartInfo = new ProcessStartInfo();
                        StartInfo.FileName = "ps";
                        StartInfo.Arguments = "-eaw -o pid,comm";
                        StartInfo.CreateNoWindow = true;
                        StartInfo.UseShellExecute = false;
                        StartInfo.RedirectStandardOutput = true;
 
                        Process Proc = new Process();
                        Proc.StartInfo = StartInfo;
                        try
                        {
                                Proc.Start();
                                Proc.WaitForExit(); // Licensee moved this to _after_ the for-loop.
                                for (string Line = Proc.StandardOutput.ReadLine(); Line != null; Line = Proc.StandardOutput.ReadLine())
                                {
                                        Line = Line.Trim();
                                        int PIDEnd = Line.IndexOf(' ');
                                        string PIDString = Line.Substring(0, PIDEnd);
                                        if (PIDString != "PID")
                                        {
                                                string Filename = Line.Substring(PIDEnd + 1);
                                                int Pid = Int32.Parse(PIDString);
                                                try
                                                {
                                                        Process ExistingProc = Process.GetProcessById(Pid);
                                                        if (ExistingProc != null && Pid != Process.GetCurrentProcess().Id && ExistingProc.HasExited == false)
                                                        {
                                                                ProcessInfo ProcInfo = new ProcessInfo(ExistingProc.Id, Path.GetFileName(Filename), Filename);
                                                                Result.Add(ProcInfo);
                                                        }
                                                }
                                                catch { }
                                        }
                                }
 
                        }
Steps to Reproduce

Unknown

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-114162 in the post.

0
Login to Vote

Fixed
ComponentUE - Foundation - Cpp Tools
Affects Versions4.26.2
Target Fix4.27
Fix Commit16128274
Main Commit16128358
Release Commit16128274
CreatedApr 22, 2021
ResolvedApr 27, 2021
UpdatedNov 30, 2022
View Jira Issue