https://bugs.kde.org/show_bug.cgi?id=438097

--- Comment #34 from Ash Blake <telepath...@tutanota.com> ---
(In reply to Vlad Zahorodnii from comment #33)
> Thanks for the great analysis, Ash! This is definitely very strange. At
> quick glance, I don't see how file descriptors can be leaked in kwin.

Well, it doesn't seem to be KWin that leaks them. It happens along the way in
libwayland.

This one is perhaps more useful - same test as above, but only one window gets
created with a 16ms lifetime. It appears this is actually enough to induce the
bug, and patterns are more visible.

  close(4071)                             = 0
  recvmsg(44,...,cmsg_data=[4071],...) = 152
  close(4071)                             = 0
  recvmsg(44,...,cmsg_data=[4034],...) = 152
  close(4034)                             = 0
  recvmsg(48,...,cmsg_data=[4034, 4035],...) = 16
  recvmsg(44,...,cmsg_data=[4071],...) = 152
  close(4071)                             = 0
  recvmsg(48,...,cmsg_data=[4071, 4079],...) = 16
  recvmsg(44,...,cmsg_data=[4150],...) = 152
  close(4150)                             = 0
  recvmsg(48,...,cmsg_data=[4150, 4608],...) = 16
  recvmsg(44,...,cmsg_data=[4610],...) = 152
  close(4610)                             = 0
  recvmsg(48,...,cmsg_data=[4610, 4611],...) = 16
  recvmsg(44,...,cmsg_data=[4612],...) = 152
  close(4612)                             = 0
  recvmsg(48,...,cmsg_data=[4612, 4615],...) = 16
  recvmsg(44,...,cmsg_data=[4618],...) = 152
  close(4618)                             = 0
  recvmsg(48,...,cmsg_data=[4618, 4619],...) = 16
  recvmsg(44,...,cmsg_data=[4620],...) = 152
  close(4620)                             = 0
  recvmsg(48,...,cmsg_data=[4620, 4621],...) = 16
  ^CThese descriptors were left open:
  4034, 4035, 4071, 4079, 4150, 4608, 4610, 4611, 4612, 4615, 4618, 4619, 4620,
4621

KWin does close every descriptor it receives. However, sometimes the process
does not receive one descriptor, but two - and KWin itself is not aware of the
second one, nor is it supposed to.


This is the bug-free scenario (100ms lifetime):
  close(4622)                             = 0
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  recvmsg(44,...,cmsg_data=[4622],...) = 152
  close(4622)                             = 0
  recvmsg(48,...,cmsg_data=[4622, 5710],...) = 16
  ^CThese descriptors were left open:
  4622, 5710

(And those two descriptors got closed shortly after)

Here the same thing happens, however things happen slowly enough so that the
descriptor can get reused, hence the fd amount is not rising. 

It seems like this is not KWin's fault, but it's Wayland that is doing
something weird when marshaling those descriptors.
org_kde_plasma_window_get_icon is supposed to accept one file descriptor, and
plasmashell does give it exactly one descriptor. Things get messed up along the
way, and this is not an issue anywhere in the KDE code.

While researching the topic of SCM_RIGHTS, I stumbled upon this link:
https://gist.github.com/kentonv/bc7592af98c68ba2738f4436920868dc

This part sounds like it could be a problem here:
> However, as always, recvmsg() calls on the receiving end don't necessarily 
> map 1:1 to sendmsg() calls. Messages can be coalesced or split.

Sounds like things can get mixed up when messages are getting sent fast enough.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to