[PATCH wayland v3 00/10] Stop leaking file descriptors

Derek Foreman derekf at osg.samsung.com
Wed Dec 6 17:22:15 UTC 2017


New edition of my patch series to stop leaking file descriptors on
failed marshal/demarshal, and to fix the long standing bug where
an fd destined for a zombie isn't properly consumed on the client
side, potentially resulting in the leaked fd being passed in another
event in the same buffer.

Changes since second edition:

Daniel recommended initializing a closure's fds to -1 at creation time
instead of manually counting them.  I've done that, and also set them
back to -1 after we "use" them (serialize, dispatch, invoke).  This
way any fd in a closure that's valid is something libwayland needs
to clean up on error, and any that's -1 has either not been set yet
or has already been handed off (either to a client or to other
parts of the library that have different clean-up procedures in place
for them)

A nice side effect of that change was no longer having to add a bool
at all to tell wl_closure_destroy() that the closure had been used.

patch 1, 2, 3, 4 are new.

patch 5 is greatly simplified due to the new fd initialization/use
semantics (thanks Daniel)

The test patches now contain some comments on why they need to do all
those roundtrips.

Derek Foreman (10):
  connection: Don't declare a local variable just to takes its size
  server: Log closure before sending it
  connection: Refactor out closure allocation
  connection: Clear fds we shouldn't close to -1
  connection: Make wl_closure_destroy() close fds of undispatched
    closures
  util: Pass flags to map iterators
  client: Replace the singleton zombie with bespoke zombies
  client: Consume file descriptors destined for zombie proxies
  tests: Add a test for fd leaks on zombie objects
  tests: Check for wrong fd delivery with zombie objects

 Makefile.am           |   7 +-
 protocol/tests.xml    |  52 +++++++++++
 src/connection.c      | 143 +++++++++++++++++++++++------
 src/wayland-client.c  | 131 +++++++++++++++++++++++---
 src/wayland-private.h |  15 ++-
 src/wayland-server.c  |  25 +++--
 src/wayland-util.c    |   4 +-
 tests/display-test.c  | 249 ++++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 566 insertions(+), 60 deletions(-)
 create mode 100644 protocol/tests.xml

-- 
2.15.0



More information about the wayland-devel mailing list