Bug 107741 - DBUS_MALLOC attribute on dbus_realloc() is inappropriate
Summary: DBUS_MALLOC attribute on dbus_realloc() is inappropriate
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact: D-Bus Maintainers
URL:
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2018-08-29 18:45 UTC by Simon McVittie
Modified: 2018-08-30 17:34 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Do not apply __attribute__((__malloc__)) to dbus_realloc() (1.27 KB, patch)
2018-08-29 18:45 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2018-08-29 18:45:44 UTC
Created attachment 141362 [details] [review]
Do not apply __attribute__((__malloc__)) to dbus_realloc()

As noted in GLib commit c879f50f, gcc's interpretation of the malloc
attribute has become more strict over time, which could result in
miscompilation. The new definition is that in addition to assuming
that the returned memory block is newly-allocated, gcc now assumes
that it does not contain any valid pointers. This is OK for
uninitialized or zero-initialized memory returned by dbus_malloc()
or dbus_malloc0(), but not valid for dbus_realloc(), which might be
used for a dynamically-sized array of (structures containing)
valid pointers.

See https://gitlab.gnome.org/GNOME/glib/issues/1465

---

Also proposed for dbus-1.12 and dbus-1.10, since silent miscompilation is scary and the patch is trivial.

The annotation was added by Bug #32710.
Comment 1 Philip Withnall 2018-08-30 09:42:36 UTC
Comment on attachment 141362 [details] [review]
Do not apply __attribute__((__malloc__)) to dbus_realloc()

Review of attachment 141362 [details] [review]:
-----------------------------------------------------------------

r+++++
Comment 2 Simon McVittie 2018-08-30 16:48:37 UTC
Thanks, will merge when CI completes (should be in dbus 1.13.8, 1.12.12 and 1.10.28).
Comment 3 Simon McVittie 2018-08-30 17:34:15 UTC
Fixed in git for 1.13.8, 1.12.12 and 1.10.28


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.