From 47ba58f3e7bb7df2cc0b409735ad5f774f66492c Mon Sep 17 00:00:00 2001 From: Matthew John Cheetham Date: Mon, 25 Jul 2022 14:48:00 +0100 Subject: [PATCH] diagnose: don't await Git exit on config list Do not wait for the Git process to exit until we start reading from the stdout stream, to prevent a deadlock. This is what we do in the product code too. --- src/shared/Core/Diagnostics/GitDiagnostic.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shared/Core/Diagnostics/GitDiagnostic.cs b/src/shared/Core/Diagnostics/GitDiagnostic.cs index fe6a326a0..8066f2aaf 100644 --- a/src/shared/Core/Diagnostics/GitDiagnostic.cs +++ b/src/shared/Core/Diagnostics/GitDiagnostic.cs @@ -32,8 +32,10 @@ protected override Task RunInternalAsync(StringBuilder log, IList log.Append("Listing all Git configuration..."); Process configProc = _git.CreateProcess("config --list --show-origin"); configProc.Start(); - configProc.WaitForExit(); + // To avoid deadlocks, always read the output stream first and then wait + // TODO: don't read in all the data at once; stream it string gitConfig = configProc.StandardOutput.ReadToEnd().TrimEnd(); + configProc.WaitForExit(); log.AppendLine(" OK"); log.AppendLine("Git configuration:"); log.AppendLine(gitConfig);