[gstreamer-bugs] [Bug 545714] New: GST_READ_UINT_* and GST_WRITE_UINT_* are not always safe to use

GStreamer (bugzilla.gnome.org) bugzilla-daemon at bugzilla.gnome.org
Thu Jul 31 09:55:00 PDT 2008


If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
  http://bugzilla.gnome.org/show_bug.cgi?id=545714

  GStreamer | gstreamer (core) | Ver: HEAD CVS
           Summary: GST_READ_UINT_* and GST_WRITE_UINT_* are not always safe
                    to use
           Product: GStreamer
           Version: HEAD CVS
          Platform: Other
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: gstreamer (core)
        AssignedTo: gstreamer-bugs at lists.sourceforge.net
        ReportedBy: t.i.m at zen.co.uk
         QAContact: gstreamer-bugs at lists.sourceforge.net
     GNOME version: Unspecified
   GNOME milestone: Unspecified


+++ This bug was initially created as a clone of Bug #348114 +++

See the above bug for details.

These macros should be safe to use no matter what. Just documenting the problem
isn't really an option.

Possible solutions that come to mind:

(a) always use the slow (read+shift bytes individually) variants (ugh), maybe
add _UNSAFE variants so those who know what they're doing can use those

(b) gcc seems to have a may-alias attribute, which looks like it might be
useful (can we make it ignore the casts for aliasing purposes that way, in
combination with a few typedefs?) (if yes, what to do about other compilers)

(c) use something along the lines of:

    static inline guint64
    __gst_gimme64 (const guint8 * mem)
    {
      guint64 n;
      memcpy (&n, mem, 8);
      return n;
    }

    #if G_ENDIANNESS == G_LITTLE_ENDIAN
    #define GST_READ_UINT64_LE(mem) __gst_gimme64(mem)
    #else
    ...
    #endif

and trust that the compiler will be clever enough to optimize away the memcpy
(which recent gcc seems to do with >= -O1, no idea about other compilers). This
isn't entirely pretty, but at least has the nice side-effect that we don't need
to special-case based on GST_HAVE_UNALIGNED_ACCESS any longer (right?).

Opinions? Anyone?


-- 
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.

You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=545714.




More information about the Gstreamer-bugs mailing list