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 660955 - gst_type_register_static_full: guard against large instance sizes that don't fit into a guint16
gst_type_register_static_full: guard against large instance sizes that don't ...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.32
Other All
: Normal normal
: 0.10.36
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-10-05 06:15 UTC by mpaklin
Modified: 2011-10-10 18:44 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description mpaklin 2011-10-05 06:15:54 UTC
Suppose I made a mistake (I actually did!) and had my element instance size exceed 16 bit. I used GST_BOILERPLATE_FULL() to declare it.
GST_BOILERPLATE_FULL() calls gst_type_register_static_full() to register new type with glib.

For some reason that I don't understand gst_type_register_static_full() declares instance_size parameter as guint and then internally casts it into guint16 probably suppressing corresponding warning(s). Why?

If it were to declare instance_size as guint16, the compiler would (hopefully) throw a warning if sizeof(type) exceeded 16 bit. That would caught an unsuspecting dev right there on the spot.

I filed a bug against glib to see if they could add an assert or something if the type size exceeds 16 bit. See https://bugzilla.gnome.org/show_bug.cgi?id=659916.
However in this case they obviously can't do anything as the cast to guint16 has been done already by gst_type_register_static_full().

I suggest changing instance_size parameter of gst_type_register_static_full() to guint16. If that is not possible for compatibility or some other reason, consider adding an assert to gst_type_register_static_full() to ensure that passed instance_size is within the range.

Regards,
-- Max Paklin.
Comment 1 Tim-Philipp Müller 2011-10-10 18:44:41 UTC
Can't change the function signature in the ABI stable series unfortunately, but we can of course add some guards:

In 0.10 stable branch:

commit 56e27b0546a358c237737cace96c59623a0a858e
Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
Date:   Mon Oct 10 19:41:33 2011 +0100

    utils: catch invalid instance sizes in gst_type_register_static_full()
    
    Add guards to catch overly large instance sizes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660955


In 0.11 branch:

commit 01c11ebf082aeec5b8f68ece1530c451f23b1822
Author: Tim-Philipp Müller <tim.muller@collabora.co.uk>
Date:   Mon Oct 10 19:30:34 2011 +0100

    utils: remove gst_type_register_static_full()
    
    It was only really used by GST_BOILERPLATE, and that is no more.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=660955