GNOME Bugzilla – Bug 627677
Crash in Gst.Caps.RemoveStructureReferences ()
Last modified: 2010-08-23 08:59:23 UTC
Created attachment 168532 [details] Testcase In .Net it is not possible to remove elements from the Hashtable while enumerating over its values. Calling RemoveStructureReferences on a Caps with more than one structure gives the following exception. Unhandled Exception: System.InvalidOperationException: Hashtable.Enumerator: snapshot out of sync. at System.Collections.Hashtable+Enumerator.FailFast () at System.Collections.Hashtable+Enumerator.MoveNext () at Gst.Caps.RemoveStructureReferences () at Gst.Caps.Merge (Gst.Caps caps) at capstest.Main () Attached is a minial testcase that shows the behaviour.
Created attachment 168533 [details] [review] Proposed patch This is one possible workaround
Created attachment 168534 [details] [review] Proposed patch And another possible remedy. Choose whichever patch you like.
Both patches solve the exception in the testcase. I checked the rest of the gstreamer-sharp codebase for this kind of pattern, but in other places there aren't any elements removed from the Hashtable, so Gst.Caps should be the only place that needs a fix.
Comment on attachment 168534 [details] [review] Proposed patch I prefer this one, thanks. It makes the copy of the hash table unnecessary and should be more efficient.
Author: Maarten Bosmans <mkbosmans@gmail.com> Date: Mon Aug 23 10:54:41 2010 +0200 Don't modify hash tables while iterating over them This caused crashes for caps with more than a single struct when unreffing them in one way or another. Fixes bug #627677.