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 677994 - Element.SetDetails() crashes due to wrong heap
Element.SetDetails() crashes due to wrong heap
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-sharp
git master
Other Windows
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-06-13 10:03 UTC by Petteri Aimonen
Modified: 2014-03-02 20:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.08 KB, text/plain)
2012-06-13 10:03 UTC, Petteri Aimonen
Details

Description Petteri Aimonen 2012-06-13 10:03:01 UTC
Created attachment 216251 [details]
patch

Calling Element.SetDetails() on an element subclass that overrides e.g. OnChangeState() or binds events otherwise crashes in g_free().

Reason boils down to wrong marshalling of string fields. Element.GstElementClass contains ElementDetails, which in turn contains string fields for the description etc. Currently they are declared as 'string' in C#, which causes Marshal.StructureToPtr() to allocate them using SysAllocString().

Under Windows atleast, SysAllocString() uses a different heap than g_malloc(), so the string fields cannot be freed using g_free(). The code in gst_element_set_details_simple() tries to do exactly this and crashes.

This patch changes the ElementDetails string fields to IntPtr to avoid unnecessary marshaling and reallocation. ElementDetails is declared as internal and not used elsewhere, so changing the types does not affect applications.
Comment 1 Sebastian Dröge (slomo) 2014-03-02 20:56:46 UTC
This is fixed now with the new 1.x based bindings.