Skip to content

System.AccessViolationException on avcodec_open2 #38

@forlayo

Description

@forlayo

Note: for support questions, please use stackoverflow or special repository on [github.com](in special repository github.com). This repository's issues are reserved for feature requests and bug reports.

  • **I'm submitting a ... **

    • bug report
    • feature request
    • support request or question => Please do not submit support request or questions here, see note at the top of this template.
  • Do you want to request a feature or report a bug?

I want to report a bug.

  • What is the current behavior?

Sometimes I got System.AccessViolationException when calling avcodec_open2, making impossible to catch the issue to fallback or to retry or so; as the application closes.

  • *If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem:

It happens to me time by time depending on the options I choose on the codec, but for example is reproducible 100% on a device that has a NVIDIA GeForce MX350 graphics card when I do select to open an h264_nvenc with mode AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX using AV_PIX_FMT_CUDA and AV_HWDEVICE_TYPE_CUDA.

But as I said, I think any problem that makes avcodec_open2 fail in a specific manner let me on a crash of this type.

  • What is the expected behavior?

Open the codec or getting a controlled error.

  • What is the motivation / use case for changing the behavior?

As currently is not usable.

  • Please tell us about your environment:
    I am using it on a Windows 11 device with NVIDIA GeForce MX350 graphics card.
  • version:
    Latest version v6.0.0.2
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

On FFmpeg logs I can see something like:

[h264_nvenc @ 000001f473fcc480] OpenEncodeSessionEx failed: unsupported device (2): (no details)

The crash I am getting.

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at FFmpeg.AutoGen.DynamicallyLoadedBindings+<>c.<Initialize>b__2_494(FFmpeg.AutoGen.AVCodecContext*, FFmpeg.AutoGen.AVCodec*, FFmpeg.AutoGen.AVDictionary**)
   at FFmpeg.AutoGen.ffmpeg.avcodec_open2(FFmpeg.AutoGen.AVCodecContext*, FFmpeg.AutoGen.AVCodec*, FFmpeg.AutoGen.AVDictionary**)
   at GraphicsCheck.FfmpegChecker.StartEncoder(Omni.Platforms.Windows.Services.AV.CodecInfo, Int32, Int32, Int32)
   at GraphicsCheck.FfmpegChecker.CheckConfig(CodecConfig)
   at Program.<Main>$(System.String[])

I am reproducing it with this demo project:
GraphicsCheck.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions