Bug 497602

Summary: With NVIDIA GPU, Plasmashell can crash with "Too many open files" after generating enough window previews in Task Manager
Product: [Plasma] plasmashell Reporter: jakubg1.100
Component: Task Manager and Icons-Only Task Manager widgetsAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: crash CC: ahiemstra, john.kizer, nate, qydwhotmail, xaver.hugl
Priority: NOR    
Version First Reported In: 6.2.3   
Target Milestone: 1.0   
Platform: Fedora RPMs   
OS: Linux   
URL: https://forums.developer.nvidia.com/t/fd-leak-with-explicit-sync-and-kde-plasma/317293
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report: https://crash-reports.kde.org/organizations/kde/issues/91150/events/f30ccc40f6914260a60ee5a4deac2cdf/
Attachments: Recording of the bug

Description jakubg1.100 2024-12-17 13:22:21 UTC
Created attachment 176708 [details]
Recording of the bug

SUMMARY
In the Task Manager, when the window previews are turned on, whenever I hover an application with at least one window open, the previews for that windows are generated. However, after a certain number of previews have been generated over the lifecycle of the plasmashell, the plasmashell crashes. The following lines always accompany the crash:
```
kpipewire_logging: Could not connect to stream
KCrash: Attempting to start /usr/bin/plasmashell
Failed to open metadata file: Too many open files
KCrash: Application 'plasmashell' crashing... crashRecursionCounter = 2
Segmentation fault (core dumped)
```
The most likely reason as to why it happens is because each time the window preview is generated, a file is opened, but then it is never closed, leading to a "leak". After enough of these files are "leaked" (left open) to exceed the maximum amount of open files, the window preview cannot be generated, leading to a crash.
The leaked files are never closed, which means that they accumulate over time and the crash will eventually happen if the system is not restarted frequently. However, the process can be sped up rapidly by hovering over two task manager entries with a lot of windows open and quickly alternating between them, which makes the bug easily reproducible.

STEPS TO REPRODUCE
1. Make sure the window previews are enabled in the task manager configuration.
2. Open several instances of two applications.
3. Make sure both of the applications lay next to each other in the task manager.
4. Hover over one of the applications' icons.
5. Quickly alternate between hovering one and the other application for about a minute, until plasmashell crashes. This is usually indicated by the taskbar disappearing.

OBSERVED RESULT
Plasmashell crashes, and the taskbar disappears. This can also cause other side effects.

EXPECTED RESULT
Plasmashell never crashes and allows the user to alternate between the applications indefinitely.

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.7-300.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 1 Nate Graham 2024-12-17 17:40:23 UTC
I suspect it's the pipewire screencasts for window thumbnails.
Comment 2 jakubg1.100 2024-12-17 18:09:14 UTC
(In reply to Nate Graham from comment #1)
> I suspect it's the pipewire screencasts for window thumbnails.

Makes sense, as I can see the screencasts in qpwgraph. Probably the handle isn't closed correctly, though the blocks in qpwgraph do disappear. I haven't looked into the source code to confirm this.
Comment 3 John Kizer 2025-01-24 17:41:58 UTC
Hi - just to check, what graphics card and driver are you using? (On the chance that it's https://forums.developer.nvidia.com/t/fd-leak-with-explicit-sync-and-kde-plasma/317293 )
Comment 4 jakubg1.100 2025-01-24 18:08:10 UTC
Yep - it's most likely that. I am using an NVIDIA graphics card with 565 drivers and explicit sync enabled.
Just to be clear, here's the entire `kinfo` output. I have no idea why I've omitted the hardware information beforehand.
```
$ kinfo
Operating System: Fedora Linux 41
KDE Plasma Version: 6.2.3
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.11.7-300.fc41.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 24 × 13th Gen Intel® Core™ i7-13700KF
Memory: 31.2 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 4070/PCIe/SSE2
```
and also the driver version:
```
$ nvidia-smi
Fri Jan 24 19:03:43 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 565.57.01              Driver Version: 565.57.01      CUDA Version: 12.7     |
|-----------------------------------------+------------------------+----------------------+
```

Let me know if you need any more details!
Comment 5 John Kizer 2025-01-24 18:15:50 UTC
Thanks - unfortunately that would indicate that this is the same upstream NVIDIA driver bug that I and others have run into. That URL up above (I put into the URL field of this bug as well) is, as far as I know, the closest thing to a publicly tracked "bug report" that NVIDIA has. There was also a comment noted in the overall version 565 "feedback & discussion" thread: https://forums.developer.nvidia.com/t/565-release-feedback-discussion/310777/365 

I'd recommend following updates there :-)