Skip to content

Commit 1effea1

Browse files
paulirwinclaude
andcommitted
Fix TestIndexWriterOnJRECrash fork on ARM64 hosts
GetTargetPlatform() returned "x64" on any 64-bit process, which on Apple Silicon (and other ARM64 hosts) caused the forked vstest to abort with "Could not find 'dotnet' host for the 'X64' architecture". The fork never connected back to the parent's TCP listener, so the parent blocked forever in WaitForProcessId until the assembly Timeout fired. Detect the architecture via RuntimeInformation.ProcessArchitecture so the fork runs in the same architecture as the parent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cf5910b commit 1effea1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Lucene.Net.Tests/Index/TestIndexWriterOnJRECrash.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Net;
1212
using System.Net.Sockets;
1313
using System.Reflection;
14+
using System.Runtime.InteropServices;
1415
using System.Threading;
1516
using BaseDirectoryWrapper = Lucene.Net.Store.BaseDirectoryWrapper;
1617
using Assert = Lucene.Net.TestFramework.Assert;
@@ -242,7 +243,19 @@ private string GetTargetFramework()
242243

243244
private static string GetTargetPlatform()
244245
{
245-
return Environment.Is64BitProcess ? "x64" : "x86";
246+
// LUCENENET: Match the host process architecture so the forked vstest can
247+
// locate a compatible dotnet host. On Apple Silicon and other ARM64 hosts,
248+
// returning "x64" here causes the fork to fail with "Could not find 'dotnet'
249+
// host for the 'X64' architecture", which leaves the parent blocked forever
250+
// in WaitForProcessId.
251+
return RuntimeInformation.ProcessArchitecture switch
252+
{
253+
Architecture.X86 => "x86",
254+
Architecture.X64 => "x64",
255+
Architecture.Arm => "ARM",
256+
Architecture.Arm64 => "ARM64",
257+
_ => Environment.Is64BitProcess ? "x64" : "x86",
258+
};
246259
}
247260
#endregion
248261

0 commit comments

Comments
 (0)