Bug 496746 - kwin_wayland crash with amdgpu+nouveau for file descript
Summary: kwin_wayland crash with amdgpu+nouveau for file descript
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: generic-crash (show other bugs)
Version: 6.2.3
Platform: Arch Linux Linux
: NOR crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-11-27 09:51 UTC by anonymous.34197
Modified: 2024-11-29 16:50 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.2.5
Sentry Crash Report:


Attachments
tools to log the activity of file descriptor for kwin_wayland, just run it and wait until exit. in the cwd of the tool are been created loggerOut_poll.txt and loggerOut_ioctl.txt, which are the logs (1.35 KB, text/x-python)
2024-11-27 09:51 UTC, anonymous.34197
Details
file descriptor log (366.35 KB, application/gzip)
2024-11-27 22:45 UTC, anonymous.34197
Details

Note You need to log in before you can comment on or make changes to this bug.
Description anonymous.34197 2024-11-27 09:51:01 UTC
Created attachment 176162 [details]
tools to log the activity of file descriptor for kwin_wayland, just run it and wait until exit. in the cwd of the tool are been created loggerOut_poll.txt and loggerOut_ioctl.txt, which are the logs

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports

Please remove this comment after reading and before submitting - thanks!
***

SUMMARY
while using kde in wayland with two gpu and two monitor (one amd(amdgpu) and one nvidia(nouveau) only for use the second monitor, I refuse to use the nvidia one as primary because is good only for a display adapter and i don't switch back to 1 monitor after years of using two monitor, one monitor for gpu) i noticed repetitive crashing for file descriptor, i increased it, but nothing changed, after investigating a while i noticed that kwin continue spawning fd in POLLIN, most of it are use 1 or 2 times, and are leaved opened. This only happen when i'm using as primary gpu the amd one, while i'm using the nvidia kwin_wayland doesn't continue spawning file descriptor

STEPS TO REPRODUCE
Install amdgpu, nouveau
use amdgpu as primary gpu (both amdgpu and nouveau enabled, altroutgh it's work fine)
start KDE with wayland
use the pc for daily use (to accelerate the crash, it's recommended to open a game)

OBSERVED RESULT
file descriptor constant increase while using the pc and after a few hours reaching more than 100k fd and kwin_wayland crash + increase memory usage over time


EXPECTED RESULT
kwin_wayland don't continue opening fd, like when the nouveau gpu is set as primary one 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 6.12.1-arch1-1 (64-bit)
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0

ADDITIONAL INFORMATION
nov 26 21:44:38 archlinux kwin_wayland[263153]: gbm_bo_get_fd_for_plane() failed: Too many open files
nov 26 21:44:38 archlinux kwin_wayland[263153]: kwin_screencast: "" Could not connect to stream
nov 26 21:44:38 archlinux kwin_wayland[263153]: kwin_screencast: "" Failed to create PipeWire stream
nov 26 21:44:38 archlinux plasmashell[263149]: error creating screencast "Failed to create PipeWire stream"
nov 26 21:44:39 archlinux kwin_wayland_wrapper[263153]: file descriptor expected, object (122), message add(huuuuu)
nov 26 21:44:39 archlinux kwin_wayland_wrapper[263153]: error in client communication (pid 263153)
nov 26 21:44:39 archlinux kwin_wayland_wrapper[263192]: XWAYLAND: wl_display#1: error 1: invalid arguments for zwp_linux_buffer_params_v1#122.add
nov 26 21:44:39 archlinux kwin_wayland_wrapper[263192]: (EE) failed to dispatch Wayland events: Invalid argument
nov 26 21:44:39 archlinux kwin_wayland[263153]: kwin_xwl: The X11 connection broke (error 1)

below i attach the pyhon tool that i created to analyze the fd poll IO status
Comment 1 Vlad Zahorodnii 2024-11-27 14:46:40 UTC
Can you please capture the contents of `ls -l /proc/$(pidof kwin_wayland)/fd` when the issue happens the next time? You may need to run the ls command with sudo
Comment 2 TraceyC 2024-11-27 15:55:24 UTC
Setting this to waiting for info
Comment 3 anonymous.34197 2024-11-27 16:26:57 UTC
(In reply to Vlad Zahorodnii from comment #1)
> Can you please capture the contents of `ls -l /proc/$(pidof
> kwin_wayland)/fd` when the issue happens the next time? You may need to run
> the ls command with sudo

In general the content it's a lot of a_inode:sync_file, in any case i create a program to log the fd for kwin.
Comment 4 anonymous.34197 2024-11-27 22:45:02 UTC
Created attachment 176177 [details]
file descriptor log
Comment 5 anonymous.34197 2024-11-27 22:51:28 UTC
After spent 7 hours to achieve only two crash i can't get the "ls -l /proc/$(pid)/fd" with the max of fd that kwin_wayland can open (529k), during when it's alive i run it, and i collected "only" 136K fd i know that was requested when it crash, but it took me every time at least 3 hours.
during this time i did more testing and i find out that it starts spawning fd when an update occurs on the display attached to the nvidia gpu
Comment 6 Vlad Zahorodnii 2024-11-28 10:18:20 UTC
(In reply to anonymous.34197 from comment #3)
> (In reply to Vlad Zahorodnii from comment #1)
> > Can you please capture the contents of `ls -l /proc/$(pidof
> > kwin_wayland)/fd` when the issue happens the next time? You may need to run
> > the ls command with sudo
> 
> In general the content it's a lot of a_inode:sync_file, in any case i create
> a program to log the fd for kwin.

Okay, it seems like native fence file descriptors are leaked somehow.
Comment 7 David Edmundson 2024-11-29 12:20:21 UTC
Should be fixed by: https://invent.kde.org/plasma/kwin/-/merge_requests/6847