After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 627677 - Crash in Gst.Caps.RemoveStructureReferences ()
Crash in Gst.Caps.RemoveStructureReferences ()
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-sharp
git master
Other All
: Normal critical
: 0.9.3
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-08-22 22:58 UTC by Maarten Bosmans
Modified: 2010-08-23 08:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Testcase (448 bytes, application/octet-stream)
2010-08-22 22:58 UTC, Maarten Bosmans
  Details
Proposed patch (517 bytes, patch)
2010-08-22 23:00 UTC, Maarten Bosmans
rejected Details | Review
Proposed patch (473 bytes, patch)
2010-08-22 23:01 UTC, Maarten Bosmans
committed Details | Review

Description Maarten Bosmans 2010-08-22 22:58:34 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.
Comment 1 Maarten Bosmans 2010-08-22 23:00:38 UTC
Created attachment 168533 [details] [review]
Proposed patch

This is one possible workaround
Comment 2 Maarten Bosmans 2010-08-22 23:01:48 UTC
Created attachment 168534 [details] [review]
Proposed patch

And another possible remedy.

Choose whichever patch you like.
Comment 3 Maarten Bosmans 2010-08-22 23:07:01 UTC
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 4 Sebastian Dröge (slomo) 2010-08-23 08:56:40 UTC
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.
Comment 5 Sebastian Dröge (slomo) 2010-08-23 08:59:23 UTC
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.