Bug 465517

Summary: plasmashell tries to parse an ELF executable whose name ends in ".desktop" as an XDG desktop entry, only in very specific circumstances
Product: [Plasma] plasmashell Reporter: Avraham Hollander <anhollander516>
Component: generic-performanceAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: minor CC: kde
Priority: NOR    
Version First Reported In: 5.26.5   
Target Milestone: 1.0   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: A portion of plasmashell's log showing the described errors

Description Avraham Hollander 2023-02-09 19:23:00 UTC
Created attachment 156108 [details]
A portion of plasmashell's log showing the described errors

SUMMARY
plasmashell tries to parse an executable whose name ends in ".desktop" contained inside an AppImage as an XDG desktop entry. This results in 100% load on a thread until it reaches the end of the file.

STEPS TO REPRODUCE
1. Download https://client2.krunker.io/setup.AppImage. This is a program that causes the bug to manifest. Its main executable upon extraction is io.krunker.desktop.
2. Run the AppImage.

OBSERVED RESULT
For 10-15 seconds, plasmashell uses 100% of a CPU as it tries to parse the ELF executable "io.krunker.desktop" as a desktop entry. The journalctl log for plasmashell is spammed with errors about invalid entries and escape sequences throughout the executable file. There is no noticeable impact on the application's performance, but that is only on my system with nothing else running in the background.

EXPECTED RESULT
plasmashell realizes the executable is an executable and ignores it.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Arch Linux
(available in About System)
KDE Plasma Version: 5.26.5
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
This bug still occurs even when extracting the AppImage and running io.krunker.desktop directly. I have not been able to reproduce this by adding a .desktop extension to other executables.
Comment 1 David Redondo 2023-02-10 13:51:24 UTC
> plasmashell realizes the executable is an executable and ignores it.

Seems to be hard we and glib and xdg-mime (outside of a kde session= agree that the file is a desktopfile

$ kmimetypefinder5 io.krunker.desktop
application/x-desktop

$ gio info  io.krunker.desktop
[...]
  standard::content-type: application/x-desktop
  standard::fast-content-type: application/x-desktop
[...]

$mimetype  io.krunker.desktop 
io.krunker.desktop: application/x-desktop
Comment 2 Avraham Hollander 2023-02-11 21:43:03 UTC
(In reply to David Redondo from comment #1)
> > plasmashell realizes the executable is an executable and ignores it.
> 
> Seems to be hard we and glib and xdg-mime (outside of a kde session= agree
> that the file is a desktopfile
> 
> $ kmimetypefinder5 io.krunker.desktop
> application/x-desktop
> 
> $ gio info  io.krunker.desktop
> [...]
>   standard::content-type: application/x-desktop
>   standard::fast-content-type: application/x-desktop
> [...]
> 
> $mimetype  io.krunker.desktop 
> io.krunker.desktop: application/x-desktop

Weird. There must be something else screwy upstream.