Bug 482298 - Plasma shell crashed by file dropped as layer in GIMP under Wayland
Summary: Plasma shell crashed by file dropped as layer in GIMP under Wayland
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: xwayland (show other bugs)
Version: master
Platform: Other Linux
: HI crash
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: qt6
: 473977 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-03-03 12:44 UTC by BOF
Modified: 2024-09-30 12:08 UTC (History)
6 users (show)

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


Attachments
plasma crashed on dropped layer in GIMP (3.90 MB, video/webm)
2024-03-03 12:44 UTC, BOF
Details
text in terminal of crashed shell (32.39 KB, text/plain)
2024-03-03 12:48 UTC, BOF
Details
system monitor - GIMP dropped layer (137.88 KB, image/png)
2024-03-06 09:46 UTC, BOF
Details
xwayland_100% (11.17 KB, image/png)
2024-08-28 22:35 UTC, duha.bugs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description BOF 2024-03-03 12:44:39 UTC
Created attachment 166349 [details]
plasma crashed on dropped layer in GIMP

SUMMARY
When you open a file in GIMP (right click > open with GIMP) and drop a second image as new layer GIMP goes crazy and crashes the plasma shell. Sometimes it's able to recover, other times I need to open the terminal and enter 'plasmashell start' to recover it.

-> THIS ONLY HAPPENS UNDER WAYLAND

STEPS TO REPRODUCE
1. Right click a file > open with GIMP
2. Select a second file and drag&drop it as new layer into GIMP
3. GIMP crashes the plasmashell

OBSERVED RESULT
Plasmashell is crashed and only sometimes does recover.

EXPECTED RESULT
Plasmashell is not crashed.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 6.0
KDE Plasma Version: 6.0.0
KDE Frameworks Version: 6.0.0
Qt Version: 6.6.2
Kernel Version: 6.5.0-21-generic (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 4800H with Radeon Graphics
Memory: 30.7 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: Micro-Star International Co., Ltd.
Product Name: Bravo 17 A4DDR
System Version: REV:1.0

ADDITIONAL INFORMATION
- The exact same steps do *NOT* cause a crash under X11
- Before Plasmashell was crashed I saw GIMP opening >200 dialog boxes in the background trying to import the file. To me it looked like a 'loop bug' where the dropped file somehow causes an infinite loop that results in a 
crash of the plasmashell (or something else, I have no idea)
Comment 1 BOF 2024-03-03 12:48:25 UTC
Created attachment 166351 [details]
text in terminal of crashed shell

When the plasmashell does not recover I start it with the terminal (krun > konsole > 'plasmashell start'). This is what was left in the terminal after the code of the started plasmashell
Comment 2 BOF 2024-03-03 15:01:09 UTC
Bug on the GIMP bug tracker can be found here: https://gitlab.gnome.org/GNOME/gimp/-/issues/10515
Comment 3 Nate Graham 2024-03-05 18:49:40 UTC
Are you dragging the files from Dolphin or the Plasma desktop?

What kind of files are you dragging? Does it happen with all files and file types tested, or only some?
Comment 4 BOF 2024-03-06 09:46:33 UTC
Created attachment 166470 [details]
system monitor - GIMP dropped layer

(In reply to Nate Graham from comment #3)
> Are you dragging the files from Dolphin or the Plasma desktop?
> 
> What kind of files are you dragging? Does it happen with all files and file
> types tested, or only some?

In the video example I was dragging the files from the Plasma desktop. But the crash can also be reproduced with drag&drop from Dolphin.
In the example it was png files, but I got the same result with jpg files.

In general the crash happens with all files. Sometimes Plasma crashes with the same files in one session but only imports one image as >100 layers the next time after a reboot.
Some different behaviour could be related to png files or large tiff files as they tend to crash GIMP less often (but crash plasma nonetheless). This _could_ also be related to their resolution since it seems to be less problematic when you drop a file with smaller resolution on a bigger with larger resolution. HOWEVER: This is just wild speculation on my part.

You have to drop the file *in the layers section* for the bug to occur. When I drop the file in the main window (where you see your image) there is no crash.

I closely watched the system monitor and as you drop the file you can see that the used RAM shoots up. Once the application hits around ~4GB in size, plasma crashes. (No idea if there is a RAM limit for individual applications or if this could be related to 32bit architecture or library somewhere)

In the attached image I was able to snapshot a moment when GIMP opened >100 tasks and the RAM shot up to ~11 GB (was at ~400 MB with only one image)
Comment 5 TraceyC 2024-08-28 21:48:37 UTC
Thank you for the bug report, and the detailed information. In order to find out the cause of the crash in plasmashell, we need a backtrace of plasmashell when this crash occurs (I did see the backtrace of the GIMP in the report on that tracker). Could we ask you to add a plasmashell backtrace to this report?
Comment 6 duha.bugs 2024-08-28 22:35:13 UTC
Created attachment 173062 [details]
xwayland_100%

So while I can't make it crash I know (probably) why it crashes:

Once I add the second image to the layer it errors out with: "imp: Gimp-Widgets-WARNING: Received invalid file data!" 


Which continuously tries to add new layers which makes xwayland go close to 100% CPU (and laggs really bad) and possibly crashes on lower end hardware.
Attached is the process that goes close to 100%

Moving to kwin, for further evaluation. Unsure if this can be guarded against or if this needs to be fixed on the GTK side.
Comment 7 David Edmundson 2024-09-24 10:26:35 UTC
I was able to reproduce this with the steps in the video. It's important to drag onto the layer list.
Comment 8 Bug Janitor Service 2024-09-25 12:11:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6494
Comment 9 Bug Janitor Service 2024-09-25 14:22:27 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6498
Comment 10 Vlad Zahorodnii 2024-09-26 11:09:52 UTC
Git commit 48faf8314d90426abcc8a45daf082b7627f4e9bd by Vlad Zahorodnii.
Committed on 26/09/2024 at 10:57.
Pushed by vladz into branch 'master'.

xwayland: Fix sending multiple XdndDrop messages after a drop occurs

There might be more XdndStatus client messages after a drop occurs. In
which case avoid sending XdndDrop client message again as it can result
in a feedback loop with clients such as GIMP.

M  +17   -12   src/xwayland/drag_wl.cpp
M  +2    -1    src/xwayland/drag_wl.h

https://invent.kde.org/plasma/kwin/-/commit/48faf8314d90426abcc8a45daf082b7627f4e9bd
Comment 11 Vlad Zahorodnii 2024-09-26 11:26:53 UTC
Git commit 259afc9e607e91ef5145883d4b03255f061af369 by Vlad Zahorodnii.
Committed on 26/09/2024 at 11:10.
Pushed by vladz into branch 'Plasma/6.2'.

xwayland: Fix sending multiple XdndDrop messages after a drop occurs

There might be more XdndStatus client messages after a drop occurs. In
which case avoid sending XdndDrop client message again as it can result
in a feedback loop with clients such as GIMP.


(cherry picked from commit 48faf8314d90426abcc8a45daf082b7627f4e9bd)

Co-authored-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>

M  +17   -12   src/xwayland/drag_wl.cpp
M  +2    -1    src/xwayland/drag_wl.h

https://invent.kde.org/plasma/kwin/-/commit/259afc9e607e91ef5145883d4b03255f061af369
Comment 12 Vlad Zahorodnii 2024-09-30 12:08:19 UTC
*** Bug 473977 has been marked as a duplicate of this bug. ***