Skip to content

AccessViolationException when running on Azure DevOps runner #27993

@ladenedge

Description

@ladenedge

Describe the issue

In my Azure DevOps CI pipeline, I am running into the following exception:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Microsoft.ML.OnnxRuntime.InferenceSession.Init(System.String, Microsoft.ML.OnnxRuntime.SessionOptions, Microsoft.ML.OnnxRuntime.PrePackedWeightsContainer)

This occurs at the following code:

public OnnxModel()
{
    var sessionOptions = new Microsoft.ML.OnnxRuntime.SessionOptions
    {
        InterOpNumThreads = 1,
        IntraOpNumThreads = 1,
    };

    // crash is right here
    session = new InferenceSession(SileroConfiguration.ModelLocation, sessionOptions);
}

I have installed the runtime via the following NuGet package:

<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.24.4" />

I am trying to load the model provided by Silero VAD. This model loads fine on my development machine (Windows 11), and when I deploy to my lab server (Windows Server 2022).

I am sure the native libraries are found because the SessionOptions object is created successfully.

Things I Tried

  1. I made sure the model was found. File.Exists() shows true for my model file.
  2. I tried downgrading to previous versions (1.22.1, 1.23.2) of the nuget package.
  3. I tried switching EnableCpuMemArena true and false.
  4. I tried sessionOptions.SetEpSelectionPolicy(ExecutionProviderDevicePolicy.PREFER_CPU);
  5. I tried sessionOptions.AppendExecutionProvider_CPU(0);
  6. I made sure the Azure-hosted machine supports AVX:
var hasAvx = (GetEnabledXStateFeatures() & 4) != 0;
Debug.Assert(hasAvc);

What am I doing wrong here?

To reproduce

I'm not sure how best to allow for a reproduction, since I can only make it happen on Azure DevOps runners.

Here are the stats on the DevOps image: https://github.com/actions/runner-images/blob/main/images/windows/Windows2025-VS2026-Readme.md

Urgency

No response

Platform

Windows

OS Version

Windows Server 2025 with Visual Studio 2026

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

NuGet package 1.24.4

ONNX Runtime API

C#

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETPull requests that update .net codeapi:CSharpissues related to the C# API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions