Pasting image from clipboard to Firefox causes KDE to hang

Hi, I’m running Plasma 6.2.5 Wayland session on Arch Linux, kernel 6.12.8-arch1-1.
Hardware: i7-11800H, RTX 3070 Mobile (driver v. 565.77), 32 GiB RAM.

When I open GIMP, select part of an image, copy it to clipboard, and paste it into Firefox with a website that supports pasting from clipboard (Zoho’s webmail in this case), KDE hangs - cursor disappears and the screen remains frozen.

Despite the display being frozen, the system seems to be running, because when I disconnect an USB accessory, the device disconnected sound plays through the speakers.
Switching to TTY doesn’t work.
Only way to recover is to hard reset the computer or reboot using SysRq.

This only happens when the image has higher resolution (16MP photo for example).
When I re-open GIMP after reboot, it shows a dialog saying that the program has previously crashed and whether I want to recover my data.
This seems to indicate that GIMP crashes when working with the clipboard and takes the KDE down with it.

I’m wondering whether this is a KDE bug or an nVidia bug, or something else even.
I guess it could also be something to do with Firefox or GIMP, but I don’t think the DE should allow user app to cause it to freeze/crash anyway.

Anyways. I have no idea where to even start investigating, where to find relevant logs to share, in order to write an useful bug report.

Any help would be appreciated.

Have you tried other combinations of programs?

E.g. pasting into Dolphin or copying from Gwenview?

Good point.

Gwenview → Dolphin is OK.
Gwenview → Firefox is also OK.
GIMP → Dolphin is OK.
GIMP → Firefox is broken - DE freezes.

Both Firefox and GIMP are installed as native apps. Their respective versions are:
Firefox: 134.0-1
GIMP: 2.10.38-5

Hi!

The catch there is that what applications are allowed to do to the overall system is, in large part, controlled by system components at a layer below the desktop environment - ex. things like the kernel and its OOM killer.

Heading to your Application Launcher and running the Crashed Processes Viewer might help give a lead on which application is crashing first, by checking the timestamps correlating to when it happened? If that shows you which application went down first, then following the “Retrieving a backtrace using coredumpctl” section here might help get the details needed for a solid bug report, whether it’s to the KDE Bugtracking System for KDE software, or to the appropriate project if it’s not.

I don’t know if this will be helpful in the process, but interestingly, there has been an X11 version of a seemingly similar situation before, that was driven by an upstream Qt issue: GIMP crashing when a Qt clipboard manager or another Qt application with similar clipboard interaction is running (#789) · Issues · GNOME / GIMP · GitLab

1 Like

Oh, I had not know that existed :+1:

I don’t know if this will be helpful in the process, but interestingly, there has been an X11 version of a seemingly similar situation before

Checking if the problem also exists on X11 might be helpful even if unrelated to that other bug.

Other think I just thought of would be to check if drag & drop works instead (assuming that GIMP supports dragging out of it).

@johnandmegh
Thanks for the explanation.
Bummer the Kernel doesn’t treat the DE in any special way, giving it some preference over other apps.
I think Windows has gotten this right, no misbehaving program ever prevented me from opening a task manager and killing it, though I do remember how slow that sometimes was during the XP era.
Loosing keyboard/mouse input and video output on Linux/Wayland/KDE because of a misbehaving program is a tad unfortunate behavior from user perspective, as it leaves no room to recover the system, resulting in data loss.

Crashed Processes Viewer sadly doesn’t contain anything of relevance, only old reports of Spotify and ADB crashing.

@krake
I’ll try to install X11 and try to reproduce it there during next weekend (can’t risk breaking the system during the week when I’m working).

I’m afraid there is no way to drag a selection of picture from GIMP, at least I was not able to find any.

Thinking about what I wrote, I search the web for more frozen system recovery options on Linux, and found a SysRq shortcut that invokes OOM killer for cases when the freeze is caused by low available memory.

Invoking OOM killer by SysRq+F kills Firefox and the DE immediately recovers.
It would be nice if KDE was able to this automatically when the DE is effectively frozen because of the low memory situation, since most users will have no idea what’s going on (+SysRq is usually disabled by default) and will have to hard-reset anyway.
I left the system on for couple of hours last time and it never self-recovered, just remained frozen.

Below is the dmesg log from OOM execution.

[76593.252478] sysrq: Manual OOM execution
[76593.252659] kworker/0:1 invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL), order=-1, oom_score_adj=0
[76593.252669] CPU: 0 UID: 0 PID: 39269 Comm: kworker/0:1 Tainted: G           OE      6.12.9-arch1-1 #1 4fef9133193e91ac7130a5fb3d3ffb90eed417ef
[76593.252677] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
[76593.252679] Hardware name: LENOVO 82K6/LNVNB161216, BIOS H1CN58WW 04/11/2024
[76593.252682] Workqueue: events moom_callback
[76593.252695] Call Trace:
[76593.252699]  <TASK>
[76593.252704]  dump_stack_lvl+0x5d/0x80
[76593.252714]  dump_header+0x44/0x18d
[76593.252719]  oom_kill_process.cold+0x8/0x8a
[76593.252723]  out_of_memory+0x219/0x4b0
[76593.252729]  moom_callback+0x7a/0xb0
[76593.252736]  process_one_work+0x17b/0x330
[76593.252743]  worker_thread+0x2ce/0x3f0
[76593.252749]  ? __pfx_worker_thread+0x10/0x10
[76593.252755]  kthread+0xcf/0x100
[76593.252763]  ? __pfx_kthread+0x10/0x10
[76593.252769]  ret_from_fork+0x31/0x50
[76593.252774]  ? __pfx_kthread+0x10/0x10
[76593.252780]  ret_from_fork_asm+0x1a/0x30
[76593.252787]  </TASK>
[76593.252790] Mem-Info:
[76593.252793] active_anon:1112857 inactive_anon:0 isolated_anon:0
                active_file:1037631 inactive_file:876904 isolated_file:0
                unevictable:2 dirty:4042 writeback:0
                slab_reclaimable:93374 slab_unreclaimable:46080
                mapped:301049 shmem:20939 pagetables:8088
                sec_pagetables:781 bounce:0
                kernel_misc_reclaimable:0
                free:4817782 free_pcp:40882 free_cma:0
[76593.252803] Node 0 active_anon:4451428kB inactive_anon:0kB active_file:4150524kB inactive_file:3507616kB unevictable:8kB isolated(anon):0kB isolated(file):0kB mapped:1204196kB dirty:16168kB writeback:0kB shmem:83756kB shmem_thp:0kB shmem_pmdmapped:0kB anon_thp:2441216kB writeback_tmp:0kB kernel_stack:15952kB pagetables:32352kB sec_pagetables:3124kB all_unreclaimable? no
[76593.252811] Node 0 DMA free:11196kB boost:0kB min:28kB low:40kB high:52kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15992kB managed:15360kB mlocked:0kB bounce:0kB free_pcp:4kB local_pcp:0kB free_cma:0kB
[76593.252821] lowmem_reserve[]: 0 977 31849 0 0
[76593.252828] Node 0 DMA32 free:1071388kB boost:0kB min:2072kB low:3072kB high:4072kB reserved_highatomic:0KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:1142464kB managed:1076492kB mlocked:0kB bounce:0kB free_pcp:1008kB local_pcp:1008kB free_cma:0kB
[76593.252836] lowmem_reserve[]: 0 0 30872 0 0
[76593.252843] Node 0 Normal free:18188544kB boost:0kB min:65476kB low:97088kB high:128700kB reserved_highatomic:0KB active_anon:4451428kB inactive_anon:0kB active_file:4150524kB inactive_file:3507616kB unevictable:8kB writepending:16168kB present:32243712kB managed:31619640kB mlocked:0kB bounce:0kB free_pcp:162516kB local_pcp:20856kB free_cma:0kB
[76593.252852] lowmem_reserve[]: 0 0 0 0 0
[76593.252858] Node 0 DMA: 1*4kB (U) 1*8kB (U) 1*16kB (U) 1*32kB (U) 0*64kB 1*128kB (U) 1*256kB (U) 1*512kB (U) 0*1024kB 1*2048kB (M) 2*4096kB (M) = 11196kB
[76593.252882] Node 0 DMA32: 9*4kB (UM) 7*8kB (UM) 6*16kB (UM) 7*32kB (M) 6*64kB (M) 6*128kB (UM) 7*256kB (UM) 4*512kB (M) 7*1024kB (UM) 5*2048kB (M) 256*4096kB (M) = 1071388kB
[76593.252908] Node 0 Normal: 34238*4kB (UME) 65585*8kB (UME) 61596*16kB (UME) 19420*32kB (UME) 4509*64kB (UME) 982*128kB (UME) 447*256kB (UME) 151*512kB (UME) 147*1024kB (UME) 136*2048kB (UME) 3634*4096kB (UME) = 18188544kB
[76593.252934] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
[76593.252937] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
[76593.252940] 1935476 total pagecache pages
[76593.252942] 0 pages in swap cache
[76593.252943] Free swap  = 33554428kB
[76593.252945] Total swap = 33554428kB
[76593.252947] 8350542 pages RAM
[76593.252948] 0 pages HighMem/MovableOnly
[76593.252950] 172669 pages reserved
[76593.252951] 0 pages cma reserved
[76593.252953] 0 pages hwpoisoned
[76593.252954] Tasks state (memory values in pages):
[76593.252955] [  pid  ]   uid  tgid total_vm      rss rss_anon rss_file rss_shmem pgtables_bytes swapents oom_score_adj name
[76593.252969] [    639]     0   639    26672    17263      395    16866         2   229376        0          -250 systemd-journal
[76593.252977] [    660]     0   660     3647     1512      217     1295         0    73728        0             0 systemd-userdbd
[76593.252983] [    671]     0   671     8960     2750      892     1858         0    90112        0         -1000 systemd-udevd
[76593.252989] [    910]    81   910     2125     1108      223      884         1    57344        0          -900 dbus-broker-lau
[76593.252994] [    911]    81   911     1552     1153      557      596         0    53248        0          -900 dbus-broker
[76593.252998] [    912]     0   912   103284     6217      925     5292         0   167936        0             0 NetworkManager
[76593.253002] [    913]     0   913    77182     2324      208     2116         0   102400        0             0 boltd
[76593.253006] [    914]     0   914     3886     2126      313     1813         0    73728        0             0 systemd-logind
[76593.253010] [    915]     0   915     3798     1836      247     1589         0    86016        0             0 systemd-machine
[76593.253014] [    928]   102   928    95596     2663      876     1787         0   110592        0             0 polkitd
[76593.253018] [    983]     0   983     4166     2873      525     2348         0    73728        0             0 wpa_supplicant
[76593.253022] [    995]     0   995     4788     2086      467     1619         0    73728        0             0 cupsd
[76593.253026] [   1030]     0  1030    38623     5427      626     4801         0   139264        0             0 sddm
[76593.253031] [   1036]     0  1036  6348777    16053     5191    10280       582   204800        0             0 Xorg
[76593.253036] [   1099]     0  1099    19547     4833      571     4262         0   135168        0             0 sddm-helper
[76593.253041] [   1105]  1000  1105     5176     3106      715     2391         0    81920        0           100 systemd
[76593.253045] [   1107]  1000  1107     5603      981      459      522         0    86016        0           100 (sd-pam)
[76593.253053] [   1117]  1000  1117    45303     4800     2413     2372        15   118784        0           200 pipewire
[76593.253057] [   1118]  1000  1118   190713    12669     2719     9950         0   294912        0           200 wireplumber
[76593.253062] [   1119]  1000  1119    52567     8125     5830     2262        33   159744        0           200 pipewire-pulse
[76593.253066] [   1125]  1000  1125     1988      951       85      865         1    61440        0           200 dbus-broker-lau
[76593.253070] [   1126]  1000  1126     1671     1230      650      580         0    53248        0           200 dbus-broker
[76593.253074] [   1133]   133  1133     5417      868       61      807         0    53248        0             0 rtkit-daemon
[76593.253079] [   1141]  1000  1141   179953    27076     8136    18937         3   413696        0             0 kwalletd6
[76593.253083] [   1142]  1000  1142    77679    14935     3231    11704         0   249856        0             0 startplasma-way
[76593.253088] [   1175]  1000  1175    59438    10192     2379     7813         0   172032        0           200 kwin_wayland_wr
[76593.253091] [   1178]  1000  1178 67192900    37112     7663    29449         0   749568        0           200 baloo_file
[76593.253095] [   1180]  1000  1180   577758    67963    17264    42550      8149  1011712        0           200 kwin_wayland
[76593.253100] [   1185]     0  1185   117151     4106      829     3277         0   143360        0             0 udisksd
[76593.253104] [   1194]  1000  1194   173454     4128      784     3344         0   176128        0           200 xdg-desktop-por
[76593.253108] [   1199]  1000  1199   151332     2370      175     2195         0   131072        0           200 xdg-document-po
[76593.253111] [   1203]  1000  1203    76412     1931      122     1809         0    90112        0           200 xdg-permission-
[76593.253115] [   1210]  1000  1210      640      491       28      463         0    49152        0           200 fusermount3
[76593.253119] [   1217]     0  1217    79512     3375     1066     2309         0   118784        0             0 upowerd
[76593.253124] [   1256]  1000  1256   132341    41601    10797    28209      2595   434176        0           200 Xwayland
[76593.253128] [   1270]  1000  1270    95105     1818      212     1605         1   102400        0           200 at-spi-bus-laun
[76593.253132] [   1281]  1000  1281     1988      981       75      905         1    57344        0           200 dbus-broker-lau
[76593.253135] [   1285]  1000  1285     1024      619       43      576         0    53248        0           200 dbus-broker
[76593.253139] [   1293]  1000  1293   101341    21763     4701    17062         0   303104        0           200 ksmserver
[76593.253143] [   1295]  1000  1295   400857    35410     8960    26446         4   540672        0           200 kded6
[76593.253147] [   1311]  1000  1311   993461   131137    72104    59033         0  1540096        0           200 plasmashell
[76593.253151] [   1312]  1000  1312    58417     1774      208     1566         0    94208        0           200 at-spi2-registr
[76593.253155] [   1321]  1000  1321   244052    23827     7036    16788         3   380928        0           200 kactivitymanage
[76593.253164] [   1333]  1000  1333    57301     1441      167     1274         0    77824        0           200 dconf-service
[76593.253168] [   1368]  1000  1368    81219    16362     3608    12754         0   200704        0           200 gmenudbusmenupr
[76593.253174] [   1369]  1000  1369   101434    22429     4779    17650         0   311296        0           200 kaccess
[76593.253178] [   1370]  1000  1370   231951    26618     7820    18795         3   421888        0           200 polkit-kde-auth
[76593.253182] [   1371]  1000  1371   285166    27429     6594    20832         3   442368        0           200 org_kde_powerde
[76593.253185] [   1372]  1000  1372   269444    29498     9899    19596         3   466944        0           200 xdg-desktop-por
[76593.253189] [   1374]  1000  1374     1989     1149      100     1049         0    57344        0           200 xsettingsd
[76593.253193] [   1375]  1000  1375    81076    16111     3498    12613         0   200704        0           200 xembedsniproxy
[76593.253197] [   1474]     0  1474    77181     2296      223     2073         0    98304        0             0 power-profiles-
[76593.253201] [   1484]  1000  1484   255196    32318     9382    22933         3   471040        0           200 kdeconnectd
[76593.253205] [   1522]  1000  1522  2555327   271871   252747    19115         9  3342336        0           200 jetbrains-toolb
[76593.253209] [   1539]  1000  1539   288624    29792     8847    20941         4   479232        0           200 DiscoverNotifie
[76593.253213] [   1543]  1000  1543     3031      692      233      459         0    49152        0           200 jetbrains-toolb
[76593.253217] [   2307]     0  2307    77361     2533      377     2156         0   106496        0             0 accounts-daemon
[76593.253221] [   3179]  1000  3179   664373    75498    25839    49654         5   880640        0           200 krunner
[76593.253225] [   3663]  1000  3663   368020   155045    86727    63862      4456  1572864        0           200 telegram-deskto
[76593.253229] [  15309]  1000 15309   183795    69912     8224    61667        21   438272        0           200 dolphin
[76593.253238] [  39541]     0 39541     3789     1640      192     1448         0    69632        0             0 systemd-userwor
[76593.253242] [  39545]     0 39545     3789     1663      224     1439         0    73728        0             0 systemd-userwor
[76593.253246] [  39546]     0 39546     3789     1686      224     1462         0    77824        0             0 systemd-userwor
[76593.253251] [  39561]  1000 39561   435110    96798    20897    74525      1376   761856        0           200 systemsettings
[76593.253255] [  39983]  1000 39983   756407   234082   215030    16492      2560  2347008        0           200 gimp-2.10
[76593.253260] [  40022]  1000 40022    31296     5266     1152     4114         0   147456        0           200 script-fu
[76593.253264] [  40265]  1000 40265  5075408   171401    59236   107393      4772  2269184        0           200 firefox
[76593.253269] [  40305]     0 40305     3717     1690      192     1498         0    73728        0             0 systemd-timedat
[76593.253273] [  40333]  1000 40333    63556    10229     2208     7956        65   208896        0           200 Socket Process
[76593.253277] [  40349]  1000 40349  6007515    78141    42581    35235       325  1957888        0           100 WebExtensions
[76593.253282] [  40356]  1000 40356   128243    13913     2720    11128        65   339968        0           200 RDD Process
[76593.253287] [  40389]  1000 40389   630623    44646     7279    37021       346   606208        0           167 Privileged Cont
[76593.253290] [  40457]  1000 40457   198220    69829     8974    60855         0   442368        0           200 plasma-browser-
[76593.253294] [  40469]  1000 40469   129313    14285     2880    11340        65   368640        0           200 Utility Process
[76593.253298] [  40486]  1000 40486   620450    28790     5344    23294       152   499712        0           100 Isolated Servic
[76593.253302] [  40489]  1000 40489  7035174   141512    98634    42349       529  2347008        0           100 Isolated Web Co
[76593.253306] [  40493]  1000 40493   613304    21893     4492    17232       169   380928        0           233 Web Content
[76593.253309] [  40571]  1000 40571   613555    20951     3456    17215       280   385024        0           233 Web Content
[76593.253313] [  40615]  1000 40615   613555    20976     3974    16730       272   389120        0           233 Web Content
[76593.253317] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/user.slice/user-1000.slice/user@1000.service/app.slice/app-firefox@fe835b36e82549aba1f5b8be8ffe369e.service,task=Web Content,pid=40493,uid=1000
[76593.253444] Out of memory: Killed process 40493 (Web Content) total-vm:2453216kB, anon-rss:17968kB, file-rss:68928kB, shmem-rss:676kB, UID:1000 pgtables:372kB oom_score_adj:233

The real question though is why this copy-and-past operation causes OOM event in the first place.
Pasting the selection into Dolphin creates ~10 MiB file, which is a lot less than 32 GiB of RAM + 32 GiB of SWAP.
I’m starting to think this is some sort of bug in Firefox.

Yeah, I do think there’s something there. For what it’s worth, I notice significantly more lag and CPU strain in Firefox than in Chromium-based browsers when dragging and dropping - even when just dragging a single ~4MB image file from Dolphin into the Proton Drive web app.

I wonder if we could find an additional “paste target” to test against.

Dolphin is great to check if it works in principle but since it only writes the pasted data into a file it is not quite the same as an application that actually consumes the data.

Firefoxm on the other hand, will likely try to interpret/decode the data to create a thumbnail.

Another thing to try would be

  1. copy in GIMP
  2. verify in KDE’s clipboard history that you have the content in there
  3. close GIMP
  4. verify the content is still in the history
  5. Paste in Firefox

I.e. making the KDE clipboard the source instead of GIMP.

Absolutely!
I would even consider testing this with a different user account so your session never gets switched from Wayland to X11

1 Like

Copying from KDE’s Clipboard History after the GIMP was closed and pasting into Firefox doesn’t result in a system freeze, the image appears in Firefox as expected.

Very interesting.

We might be looking at a case in which a certain transfer format triggered the issue.

During clipboard or drag&drop operations the source will offer its content in any number of formats and the target picks one and then gets the data in that format.

So it could be that KDE’s clipboard manager picked something like “PNG” when it received the data from GIMP but Firefox would have picked some other choice when GIMP was still the “owner” of the clipboard.

Not sure if there are any tools or logs which would give us information on such details. Might need someone with a GIMP or Firefox built from source to look into.

I had a chance to test it on Xorg session, no problem there, pasting is immediate.

Testing the same system on a different hardware (Ultra 9 185H, 32GB memory, Intel iGPU), on Wayland session, results in a DE freeze for couple of seconds, but it recovers and the image gets pasted, unlike on the hardware from the first post, where the system never recovers.

1 Like

I am wondering if we are seeing a sort of “compatibility bug”.

What if both GIMP and Firefox are running as X11 applications in your Wayland session and the communication is something like GIMP → XWayland → KWin_wayland → XWayland → Firefox?

Unfortunately I don’t really know how we could check for that.

I guess at this point it could be worthwhile to file a bug report with either of the two applications.