Bug 41048 - can crash on failed realloc; cannot be forced to crash on all failed mallocs
Summary: can crash on failed realloc; cannot be forced to crash on all failed mallocs
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: 1.4.x
Hardware: Other All
: medium enhancement
Assignee: Simon McVittie
QA Contact: John (J5) Palmieri
URL: http://cgit.freedesktop.org/~smcv/dbu...
Whiteboard:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-09-20 11:03 UTC by Simon McVittie
Modified: 2012-02-21 07:15 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
[1/2] dbus_realloc: don't crash if realloc() returns NULL while using guards (1.02 KB, patch)
2011-09-20 11:04 UTC, Simon McVittie
Details | Splinter Review
[2/2] dbus-memory: add optional checking for system malloc() (etc.) failing (5.80 KB, patch)
2011-09-20 11:04 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2011-09-20 11:03:27 UTC
libdbus tries to behave in a way suitable for a core system service, for instance by surviving (and rolling back a transaction) if memory allocators return NULL.

A bug and an enhancement in this direction:

* One call to realloc() is not checked, so libdbus crashes if it returns NULL.
  My first patch checks it.

* To debug memory issues, it would be useful to be able to put libdbus in
  a GLib-like mode where malloc failures are fatal, particularly when combined
  with a small rlimit. My second patch adds this; for the moment it depends
  on DBUS_BUILD_TESTS.
Comment 1 Simon McVittie 2011-09-20 11:04:26 UTC
Created attachment 51416 [details] [review]
[1/2] dbus_realloc: don't crash if realloc() returns NULL while using guards
Comment 2 Simon McVittie 2011-09-20 11:04:48 UTC
Created attachment 51417 [details] [review]
[2/2] dbus-memory: add optional checking for system malloc() (etc.) failing

If tests are enabled and DBUS_MALLOC_CANNOT_FAIL is set, abort on system
malloc() failures (as GLib's g_malloc does). This can be used in
conjunction with a resource limit, to turn runaway memory leaks into a
debuggable core-dump.
Comment 3 Guillaume Desmottes 2012-02-20 05:22:51 UTC
Comment on attachment 51416 [details] [review]
[1/2] dbus_realloc: don't crash if realloc() returns NULL while using guards

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

++
Comment 4 Guillaume Desmottes 2012-02-20 05:50:07 UTC
Comment on attachment 51417 [details] [review]
[2/2] dbus-memory: add optional checking for system malloc() (etc.) failing

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

++
Comment 5 Simon McVittie 2012-02-21 07:15:10 UTC
Fixed in git for 1.5.10, thanks. I didn't merge this for 1.4 in the end.


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.