AccessViolationException (gst-sharp)
Describe your issue
After some time, a WinForms/Gstreamer application crashes with an AccessViolationException. Furthermore, there are many failed unref asserts from both GStreamer and GLib.
For example: The program '[22176] WinformSample.exe' has exited with code -1073740940 (0xc0000374).
Earlier: (x100+) (WinformSample.exe:22216): GStreamer-CRITICAL **: 12:34:56.880: gst_mini_object_unref: assertion 'GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0' failed
(x1000+) (Gst1.18Test.exe:3392): GLib-CRITICAL **: 12:24:46.550: Source ID 155 was not found when attempting to remove it
Expected Behavior
No crashing, no unref errors.
Observed Behavior
Many "Critical" log statements/errors - they do not always crash the app.
When a crash occurs -
Exception thrown: 'System.AccessViolationException' in gstreamer-sharp.dll
An unhandled exception of type 'System.AccessViolationException' occurred in gstreamer-sharp.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Setup
- Operating System: Windows 10
- Software: .NET Framework 4.8, GstSharp 1.18, GStreamer MSVC 1.20.1
- Device: Computer/Laptop
- GStreamer Version: 1.20.1
- Command line: [NR in command line launch line]
Steps to reproduce the bug
- Download, compile, and run (in the debugger) the Gst-sharp samples (VideoOverlay form in WinformSample project) from: https://github.com/ttustonic/GStreamerSharpSamples
- Choose an example .mp4 file.
- Video plays.
- Observe debug log and crash.
Seems to do with the disposal (or lack-thereof) of mini-objects.
How reproducible is the bug?
Almost always, variable length of time. Always on closing of window.
Solutions you have tried
Reinstalling gst-sharp, reinstalling gstreamer 1.20, reinstalling .net framework.
Additional Information
Seems to be related to handling the messages on the Bus (pipeline.Bus.Message += HandleMessage;
). Without a handler attached, the unref errors seem to go away.
This issue has only been observed using GstSharp v1.18 or above with MSVC builds of GStreamer. v1.16.3 works without these errors.
Also observed with other pipelines not using playbin
, e.g.
videotestsrc ! video/x-raw,width=1280,height=720 ! queue ! autovideosink
ksvideosrc ! queue ! videoconvert ! autovideosink
However, these must be run from inside a WinForms program for the problem to be seen.
Log snippet
...
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:52:30.463: Source ID 240 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:52:30.463: Source ID 239 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GStreamer-CRITICAL **: 12:52:30.463: gst_mini_object_unref: assertion 'GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0' failed
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:52:30.464: Source ID 242 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GStreamer-CRITICAL **: 12:52:30.464: gst_mini_object_unref: assertion 'GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0' failed
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:52:30.464: Source ID 241 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GStreamer-CRITICAL **: 12:52:30.464: gst_mini_object_unref: assertion 'GST_MINI_OBJECT_REFCOUNT_VALUE (mini_object) > 0' failed
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:52:30.464: Source ID 244 was not found when attempting to remove it
...
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:53:29.018: Source ID 590 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:53:29.018: Source ID 589 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:53:29.018: Source ID 588 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:53:29.018: Source ID 587 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:53:29.019: Source ID 586 was not found when attempting to remove it
(Gst1.18Test.exe:11144): GLib-CRITICAL **: 12:53:29.019: Source ID 585 was not found when attempting to remove it
...