Skip to content

Commit 084871f

Browse files
committed
Fix macOS CI hang: suppress createdump in conformance tests
On macOS, the createdump tool hangs indefinitely due to ptrace/SIP restrictions when invoked by grandchild .NET processes that inherit DOTNET_DbgEnableMiniDump=1 from dotnet test --blame-crash. - Suppress mini-dump generation on macOS only for conformance child processes (the runtime still prints crash diagnostics to stderr) - Add 5-minute process timeout to conformance test runners as a safety net against any future hangs
1 parent bbc6c3d commit 084871f

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

tests/Common/Utils/NodeHelpers.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ public static ProcessStartInfo ConformanceTestStartInfo(string arguments)
8383
var repoRoot = FindRepoRoot();
8484
var binPath = Path.Combine(repoRoot, "node_modules", ".bin", "conformance");
8585

86+
ProcessStartInfo startInfo;
8687
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
8788
{
8889
// On Windows, node_modules/.bin contains .cmd shims that can be executed directly
89-
return new ProcessStartInfo
90+
startInfo = new ProcessStartInfo
9091
{
9192
FileName = $"{binPath}.cmd",
9293
Arguments = arguments,
@@ -98,7 +99,7 @@ public static ProcessStartInfo ConformanceTestStartInfo(string arguments)
9899
}
99100
else
100101
{
101-
return new ProcessStartInfo
102+
startInfo = new ProcessStartInfo
102103
{
103104
FileName = binPath,
104105
Arguments = arguments,
@@ -108,6 +109,21 @@ public static ProcessStartInfo ConformanceTestStartInfo(string arguments)
108109
CreateNoWindow = true
109110
};
110111
}
112+
113+
// On macOS, disable .NET mini-dump file generation for child processes. When
114+
// dotnet test runs with --blame-crash, it sets DOTNET_DbgEnableMiniDump=1 in the
115+
// environment. This is inherited by grandchild .NET processes (e.g. ConformanceClient
116+
// launched via node). On macOS, the createdump tool can hang indefinitely due to
117+
// ptrace/SIP restrictions, causing the entire test run to hang. Disabling mini-dumps
118+
// only suppresses the dump file creation; the runtime still prints crash diagnostics
119+
// (stack traces, signal info, etc.) to stderr, which the test captures.
120+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
121+
{
122+
startInfo.Environment["DOTNET_DbgEnableMiniDump"] = "0";
123+
startInfo.Environment["COMPlus_DbgEnableMiniDump"] = "0";
124+
}
125+
126+
return startInfo;
111127
}
112128

113129
/// <summary>

tests/ModelContextProtocol.AspNetCore.Tests/ClientConformanceTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,20 @@ public async Task RunConformanceTest(string scenario)
103103
process.BeginOutputReadLine();
104104
process.BeginErrorReadLine();
105105

106-
await process.WaitForExitAsync();
106+
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
107+
try
108+
{
109+
await process.WaitForExitAsync(cts.Token);
110+
}
111+
catch (OperationCanceledException)
112+
{
113+
process.Kill(entireProcessTree: true);
114+
return (
115+
Success: false,
116+
Output: outputBuilder.ToString(),
117+
Error: errorBuilder.ToString() + "\nProcess timed out after 5 minutes and was killed."
118+
);
119+
}
107120

108121
return (
109122
Success: process.ExitCode == 0,

tests/ModelContextProtocol.AspNetCore.Tests/ServerConformanceTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,20 @@ private void StartConformanceServer()
167167
process.BeginOutputReadLine();
168168
process.BeginErrorReadLine();
169169

170-
await process.WaitForExitAsync();
170+
using var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
171+
try
172+
{
173+
await process.WaitForExitAsync(cts.Token);
174+
}
175+
catch (OperationCanceledException)
176+
{
177+
process.Kill(entireProcessTree: true);
178+
return (
179+
Success: false,
180+
Output: outputBuilder.ToString(),
181+
Error: errorBuilder.ToString() + "\nProcess timed out after 5 minutes and was killed."
182+
);
183+
}
171184

172185
return (
173186
Success: process.ExitCode == 0,

0 commit comments

Comments
 (0)