Repository navigation
Closed
Description
Description
On Apple Silicon, my single-file app with compression enabled crashes ~90% of the time with AccessViolationException. The app simply spawns two child processes concurrently. The exact stack trace varies, which is typical of memory corruption.
Reproduction Steps
csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
<ImplicitUsings>enable</ImplicitUsings>
<SelfContained>true</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
</PropertyGroup>
</Project>
Program.cs:
using System.Diagnostics;
var tasks = Enumerable.Range(0, 2)
.Select(i => Task.Run(async () =>
{
var psi = new ProcessStartInfo
{
FileName = "/bin/echo",
Arguments = "hello!",
};
using var process = Process.Start(psi)!;
await process.WaitForExitAsync();
}));
await Task.WhenAll(tasks); dotnet publish -c Release
./bin/Release/net10.0/osx-arm64/publish/Repro➜ repro git:(main) ✗ ./bin/Release/net10.0/osx-arm64/publish/Repro
hello!
hello!
➜ repro git:(main) ✗ ./bin/Release/net10.0/osx-arm64/publish/Repro
Fatal error.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Span`1[[System.Char, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]..ctor(Void*, Int32)
at System.Diagnostics.Process.GetNextArgument(System.String, Int32 ByRef)
at System.Diagnostics.Process.ParseArgumentsIntoList(System.String, System.Collections.Generic.List`1<System.String>)
at System.Diagnostics.Process.ParseArgv(System.Diagnostics.ProcessStartInfo, System.String, Boolean)
at System.Diagnostics.Process.StartCore(System.Diagnostics.ProcessStartInfo)
at System.Diagnostics.Process.Start(System.Diagnostics.ProcessStartInfo)
at Program+<>c+<<<Main>$>b__0_1>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Program+<>c+<<<Main>$>b__0_1>d, Repro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](<<<Main>$>b__0_1>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Program+<>c+<<<Main>$>b__0_1>d, Repro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](<<<Main>$>b__0_1>d ByRef)
at Program+<>c.<<Main>$>b__0_1()
at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
hello!
[1] 24480 abort ./bin/Release/net10.0/osx-arm64/publish/Repro
➜ repro git:(main) ✗ ./bin/Release/net10.0/osx-arm64/publish/Repro
Fatal error.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.ArgumentNullException.ThrowIfNull(System.Object, System.String)
at System.Diagnostics.Process.Start(System.Diagnostics.ProcessStartInfo)
at Program+<>c+<<<Main>$>b__0_1>d.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[Program+<>c+<<<Main>$>b__0_1>d, Repro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](<<<Main>$>b__0_1>d ByRef)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[[Program+<>c+<<<Main>$>b__0_1>d, Repro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]](<<<Main>$>b__0_1>d ByRef)
at Program+<>c.<<Main>$>b__0_1()
at System.Threading.Tasks.Task`1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
[1] 24498 abort ./bin/Release/net10.0/osx-arm64/publish/Repro
hello!
Expected behavior
Process completes without error.
Actual behavior
Crashes with AccessViolationException: Attempted to read or write protected memory.
Regression?
Reproduces on .NET 7, 8, 9, and 10, with varying failure rates. .NET 6 shows "bus error" 100% of the time.
| Framework | Failures (out of 100 runs) | Failure Rate |
|---|---|---|
| net10.0 | 90 | 90% |
| net9.0 | 94 | 94% |
| net8.0 | 89 | 89% |
| net7.0 | 93 | 93% |
| net6.0 | 100 | 100% |
Known Workarounds
- Set
EnableCompressionInSingleFile=false. - Putting a
Task.Delayat process start reduces but does not eliminate the failure rate.
Configuration
- macOS 15.7.1
- Apple M4 Max (ARM64)
- SDK 10.0.101 (/usr/local/share/dotnet/sdk)
- Runtime: Microsoft.NETCore.App 10.0.1
Other information
Likely related to:
- Potential (~5% chance) AccessViolationException in ReadyToRun executable targeting RID osx.11.0-arm64/osx.12-arm64 when running a child process for the first time, and both standard output and standard error are redirected #88288
- [.NET 9] Potential (~9% chance) AccessViolationException in ReadyToRun executable targeting RID osx-arm64 when running a child process for the first time, and both standard output and standard error are redirected #112167
Those issues report ~5-9% failure rates. This minimal repro has a ~90% failure rate, which may help isolate the root cause.
Activity
adamsitnik commentedon Jan 19, 2026
I am currently working on designing new Process API. I've tried to reproduce the problem in adamsitnik/ProcessPlayground#104 using both old and new APIs, but I've failed.
git clone https://github.com/adamsitnik/ProcessPlayground.git --branch copilot/add-avrepro-console-app avrepro cd avrepro dotnet publish AVRepro/AVRepro.csproj -c Release -r osx-arm64 ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVReproI'll try to get an access to some arm64 macOS hardware.
nref commentedon Jan 19, 2026
Thanks for the follow up, Adam. I will keep ProcessPlayground in mind for future use. In my case, I'm using Playwright and can't change its direct use of
Processadamsitnik commentedon Jan 19, 2026
@nref Is there any chance you could try to run my repro?
git clone https://github.com/adamsitnik/ProcessPlayground.git --branch copilot/add-avrepro-console-app avrepro cd avrepro dotnet publish AVRepro/AVRepro.csproj -c Release -r osx-arm64 ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVRepro ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVRepro ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVRepro ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVRepro --newAPI ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVRepro --newAPI ./AVRepro/bin/Release/net10.0/osx-arm64/publish/AVRepro --newAPInref commentedon Jan 19, 2026
Hi Adam, certainly. The crash still happens, even with
newAPI.adamsitnik commentedon Jan 19, 2026
@nref Thanks a lot!
nref commentedon Jan 19, 2026
Thank you!
Fix sporadic AccessViolation in compressed single-file apps on Apple …
Fix sporadic AccessViolation in compressed single-file apps on Apple …
elinor-fung commentedon Apr 29, 2026
@nref thanks for the pared down repro - super helpful.
Исправление краша на macOS ARM64 при параллельном обходе (v2.5.4)
adamscybot commentedon Apr 30, 2026
Just a note that this seems fairly likely to solve #112167