Skip to content

[triage] upstream#7359: ObjectDetection-Onnx System.AccessViolationException: 'Attempted to read or write protected memory. #39

@github-actions

Description

@github-actions

Upstream: dotnet#7359
Status: COMPLETE
Classification: bug-report
Confidence: 0.75
Reproduced: ⏭️ Skipped
Area: ONNX
Investigated at: 2026-03-07


Triage Summary

Category: Bug Report
Reasoning: The user reports a System.AccessViolationException when building and running the official OnnxObjectDetectionApp sample project. This is unexpected behavior from an officially provided sample and indicates a defect — either in the sample itself, in the ML.NET ONNX integration, or in a native dependency version mismatch. The issue has been labeled onnx and assigned to a core team member, confirming it is treated as a bug.

Summary: The user runs the samples\csharp\end-to-end-apps\ObjectDetection-Onnx\OnnxObjectDetectionApp sample on Windows 10/11 with ML.NET v1.6 and .NET 8.0 using Visual Studio 2022 (17.13.0). Upon running the app, a System.AccessViolationException ("Attempted to read or write protected memory") is thrown. The expected behavior is a live webcam object detection overlay using ML.NET and ONNX.

Suggested Labels: bug, needs-info

Reproduction Results

Reproduction was skipped for the following reasons:

  • The sample app (OnnxObjectDetectionApp) requires a physical webcam for live video feed input, which is unavailable in this CI/Linux environment.
  • The issue is Windows-specific (reported on Windows 10/11 with Visual Studio 2022), and the System.AccessViolationException is likely tied to a native ONNX runtime interop or a platform-specific memory access issue.
  • Running the full WinForms/WPF camera capture pipeline is not feasible in a headless Linux container.

Notes

  • The issue was triaged by the ML.NET team and placed on the ML.NET Future milestone, indicating it is acknowledged but not immediately scheduled.
  • The System.AccessViolationException in ONNX contexts typically points to native memory corruption in the ONNX Runtime native library, possibly due to:
    1. A mismatch between the managed ML.NET wrapper and the native ONNX Runtime version bundled with Microsoft.ML.OnnxRuntime.
    2. The sample targeting an outdated ONNX model or API version incompatible with the current runtime.
    3. A regression introduced in a newer version of Visual Studio 2022 or .NET 8.0 runtime affecting the native P/Invoke layer.
  • The relevant source for investigation would be src/Microsoft.ML.OnnxRuntime*/ and the sample at samples/csharp/end-to-end-apps/ObjectDetection-Onnx/.

Generated by Triage Single Issue ·

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-investigationAI-investigated issuebugSomething isn't workingtriageTriage tracking issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions