Bug 465775 - plasmashell quits when window title too long
Summary: plasmashell quits when window title too long
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: 5.26.90
Platform: Debian testing Linux
: NOR normal
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords: wayland
: 467612 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-02-15 15:02 UTC by Kenny Hui
Modified: 2023-03-20 17:14 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 6.0
Sentry Crash Report:
kenny.mh.hui: Wayland+
kenny.mh.hui: X11-


Attachments
An python script which opens a empty window with Tkinter, setting the title of that window to ~7000 characters. (7.34 KB, text/x-python)
2023-02-15 15:02 UTC, Kenny Hui
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kenny Hui 2023-02-15 15:02:09 UTC
Created attachment 156276 [details]
An python script which opens a empty window with Tkinter, setting the title of that window to ~7000 characters.

SUMMARY
If an application's title is too long, plasmashell will quit for whatever reason. (Not crash)
This issue seems to be Wayland only, X11 will work fine.

This has become a problem as some (rather niche) web developer puts thousands of characters into the HTML <title> tag for fun, and plasmashell would quit everytime you visit the website. (Notably with Chromium based browser/Firefox, Falkon seems unaffected, Firefox may not be able to reproduce this, see below).

The length required to reproduce this seems to vary between system, but on my main system it's exactly 4074 characters.

STEPS TO REPRODUCE
1. Switch to Wayland session
2. Visit a website with very long title (https://freeplay.codeberg.page), or run the python code attached, which opens an empty Tkinter window with a very long title (7000 char-ish).

OBSERVED RESULT
plasmashell will quit shortly after with only the following message:
"The Wayland connection broke. Did the Wayland compositor die?"

As long as the Window with a long title still persist, plasmashell would refuse to start with the message above.

EXPECTED RESULT
Plasmashell should continue functioning normally.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian GNU/Linux
KDE Plasma Version: 5.26.90
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8
Graphics Platform: Wayland

ADDITIONAL INFORMATION
I assume there is some integration between Firefox and Plasma that prevents this from happening under Firefox.
The Window title will change to "-" on the Plasma Panel's window preview if the title is too long on an officially branded Firefox browser, and plasmashell would not crash.
But on any non-Firefox branded browser. (Firefox ESR, Unbranded Firefox CI build, Librewolf etc), the panel's window preview would still display the full title, then the entire plasmashell would quit.
(Might not be caused by the panel itself, but still should be worth noting)

Also able to reproduce this in an KDE Neon VM (Plasma 5.27.0).
Comment 1 David Redondo 2023-02-16 12:51:27 UTC
The window title is to big for the buffer 

Feb 16 13:48:35 david-thinkpad kwin_wayland_wrapper[1496]: Data too big for buffer (7468 > 4096).
Feb 16 13:48:35 david-thinkpad kwin_wayland_wrapper[1496]: error in client communication (pid 13429)
Comment 2 David Redondo 2023-02-16 12:55:05 UTC
Your observed 4074 characters is close to the 4096 Byte wayland buffer size
Comment 3 Bug Janitor Service 2023-03-14 17:00:45 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3818
Comment 4 David Edmundson 2023-03-17 12:35:44 UTC
Git commit f88ff99d82f3e2f9811d174838d28fc4339e2284 by David Edmundson.
Committed on 17/03/2023 at 12:21.
Pushed by davidedmundson into branch 'master'.

wayland: Truncate strings sent via plasmawindowmanager interface

Wayland has a limited size for strings in arguments. We should truncate
any strings that come from user-defined data before sending.

We keep the full title around within kwin as it keeps logic simpler.
Size length logic is lifted from QWaylandWindow's setTitle

M  +13   -0    src/wayland/autotests/client/test_wayland_windowmanagement.cpp
M  +17   -4    src/wayland/plasmawindowmanagement_interface.cpp

https://invent.kde.org/plasma/kwin/commit/f88ff99d82f3e2f9811d174838d28fc4339e2284
Comment 5 David Edmundson 2023-03-17 20:47:48 UTC
Git commit ec6a5e7945806afcc80f26950820a5307659fad0 by David Edmundson.
Committed on 17/03/2023 at 20:01.
Pushed by davidedmundson into branch 'Plasma/5.27'.

wayland: Truncate strings sent via plasmawindowmanager interface

Wayland has a limited size for strings in arguments. We should truncate
any strings that come from user-defined data before sending.

We keep the full title around within kwin as it keeps logic simpler.
Size length logic is lifted from QWaylandWindow's setTitle


(cherry picked from commit f88ff99d82f3e2f9811d174838d28fc4339e2284)

M  +13   -0    src/wayland/autotests/client/test_wayland_windowmanagement.cpp
M  +17   -4    src/wayland/plasmawindowmanagement_interface.cpp

https://invent.kde.org/plasma/kwin/commit/ec6a5e7945806afcc80f26950820a5307659fad0
Comment 6 David Edmundson 2023-03-20 17:14:30 UTC
*** Bug 467612 has been marked as a duplicate of this bug. ***