-
Notifications
You must be signed in to change notification settings - Fork 474
Description
Description
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Repeat 2 times:
at LLama.Native.NativeApi.llama_backend_init()
at LLama.Native.NativeApi..cctor()
at LLama.Native.NativeApi.llama_max_devices()
at LLama.Native.NativeApi.llama_max_devices()
at LLama.Abstractions.TensorSplitsCollection..ctor()
at LLama.Common.ModelParams..ctor(System.String)
at DemoApi.Services.GgufModelService+d__19.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
at DemoApi.Services.GgufModelService.LoadAsync(System.String, System.Threading.CancellationToken)
at DemoApi.Services.GgufModelService.EnsureLoadedAsync(System.Threading.CancellationToken)
at Program+<
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[[System.__Canon, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon ByRef)
at Program.$(System.String[])
at Program.(System.String[])
Reproduction Steps
Title: 🚨 Fatal System.AccessViolationException on x64 CPU backend with .NET 8
Description:
Running the Demo_net8_Onnx project with LlamaSharp CPU backend (no AVX) on Intel 11th Gen CPUs crashes immediately with a System.AccessViolationException. This happens on .NET 8 (x64) on Windows 10/11. The crash occurs before any inference, making the demo completely unusable.
Steps to Reproduce:
Clone the repository:
git clone
cd Demo_Net8_Onnx
Ensure .NET 8 SDK is installed:
dotnet --version # Should show 8.0.x
Restore NuGet packages:
dotnet restore Demo_net8_Onnx.csproj
Confirm project references include:
Build and run targeting x64:
dotnet build -r win-x64 Demo_net8_Onnx\Demo_net8_Onnx.csproj
dotnet run -r win-x64 --project Demo_net8_Onnx\Demo_net8_Onnx.csproj
Observe the crash:
Fatal error. System.AccessViolationException: Attempted to read or write protected memory...
Expected Behavior:
The demo should run successfully on CPU without AVX support.
Environment:
CPU: Intel 11th Gen
OS: Windows 10/11 x64
.NET SDK: 8.0.x
LlamaSharp Backend: CPU (no AVX)
Notes:
Crash happens instantly, even with a minimal setup.
Works only if a non-CPU backend is used or if AVX is enabled (untested).
Environment & Configuration
- Operating system:
- .NET runtime version:
- LLamaSharp version:
- CUDA version (if you are using cuda backend):
- CPU & GPU device:
Known Workarounds
No response