Bug 432669 - Corruption of screen when using ncurses when terminal resized depending on line content
Summary: Corruption of screen when using ncurses when terminal resized depending on li...
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 20.12.1
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-08 22:08 UTC by Nick
Modified: 2021-07-22 16:07 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 21.08


Attachments
Corruption shown in last line to the right of text (92.67 KB, image/png)
2021-02-08 22:08 UTC, Nick
Details
Corruption shown in last line, whole line should be light coloured (690.72 KB, image/png)
2021-02-08 22:10 UTC, Nick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nick 2021-02-08 22:08:28 UTC
Created attachment 135521 [details]
Corruption shown in last line to the right of text

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Neon/v5.20.5
KDE Plasma Version: v5.20.5
KDE Frameworks Version: v5.78.0
Qt Version: v5.12.2

ADDITIONAL INFORMATION

Corruption of konsole when using nwipe which uses ncurses. The corruption is not present in other terminal emulators, such as tmux, terminology, terminator, kitty, guake, stterm or st, rxvt-unicode. It only occurs in konsole or any terminal emulator that uses qtermwidget (Konsole) such as cool-retro-term

Please see the nwipe issue here https://github.com/martijnvanbrummelen/nwipe/issues/305 and especially the video that shows the corruption on the bottom line of the screen. These box characters also randomly appear in the main window of nwipe.

100% reproducible on Konsole v20.04.3 (KDE 5.19.4) QT v5.14.2 and possibly earlier but also in Konsole v20.12.1 (QT v5.15.1, KDE frameworks 5.78.0, Plasma 5.20.5) and later.

The attached image show the corruption in the form of random box characters, either horizontal, vertical or corner box characters and a change in the background colour of the character if it has been set, on the last line.

It seems to occur after resizing the terminal then writing a line to the terminal that is over 3/4 the column width and contains '=' symbols strangely enough. Random horizontal line also occur in the main window.
Comment 1 Nick 2021-02-08 22:10:04 UTC
Created attachment 135522 [details]
Corruption shown in last line, whole line should be light coloured
Comment 2 Solerman Kaplon 2021-03-15 20:17:14 UTC
Might be related https://www.dedoimedo.com/computers/plasma-scaling-konsole-lines.html
Comment 3 ninjalj 2021-07-03 23:12:43 UTC
nwipe does the following to write the last line:

SYS_write(1, "mq\033[98bj\033(B\033(B\033[m\033[39;49m\033[97m\033[40m\033[21;12H\033(0\033[0m\033[37m\033[44m", 60) = 60
SYS_write(1, "\033(B\033[0m\033[34m\033[47m\033[1K ", 22)            = 22
SYS_write(1, "S=Start M=Method P=PRNG V=Verify R=Rounds B=Blanking Space=Select Ctrl-C=Quit\033[K\033[7;61H", 87) = 87
SYS_write(1, "\033(B\033[m\033[39;49m\033[97m\033[40m", 24)          = 24

Notice that after printing "S=Start...", it clears to the end of line (CSI K).

and then, when pressing M to select a Method:

SYS_write(1, "\033[21;24H", 8)                                       = 8
SYS_write(1, "\033[34m\033[47m\033[1K\t", 15)                        = 15
SYS_write(1, "J=Down K=Up Space=Select Backspace=Cancel", 41)        = 41
SYS_write(1, "\033[12P\033[21;78H", 13)                              = 13
SYS_write(1, "\033(B\033[m\033[39;49m\033[97m\033[40m", 24)          = 24

so, it positions the cursor in the middle of the previous "S=Start..." status message, clears to the beginning of line (CSI 1 K), writes the new "J=Down..." message, and deletes 12 characters (CSI 12 P).

The bug appears because Konsole doesn't shrink lines when resizing (it just set a variable _columns to the maximum column available), and CSI K (Erase Line) just clears until _columns. Then when nwipe sends a CSI P (Delete CHaracters) request, which deletes some characters in the middle of the last line, characters from beyond _columns reappear.
Comment 4 Bug Janitor Service 2021-07-03 23:27:07 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/427
Comment 5 tcanabrava 2021-07-16 10:55:19 UTC
Git commit ed7fe4a2cbb8f4fc178ae83431f0190c92d39ba2 by Tomaz  Canabrava, on behalf of Luis Javier Merino Morán.
Committed on 16/07/2021 at 10:55.
Pushed by tcanabrava into branch 'master'.

Resize lines when clearing to end of line.

clearImage() just clears until _columns.  To prevent characters from
beyond _columns from reappearing, e.g. due to DCH (Delete CHaracters)
requests, make clearImage() resize lines when clearing to the end of
line.

M  +4    -0    src/Screen.cpp

https://invent.kde.org/utilities/konsole/commit/ed7fe4a2cbb8f4fc178ae83431f0190c92d39ba2
Comment 6 Kurt Hindenburg 2021-07-19 22:46:05 UTC
Git commit 7e0d300c2d08e8429b0e1997d07ce543c186767d by Kurt Hindenburg, on behalf of Luis Javier Merino Morán.
Committed on 19/07/2021 at 22:40.
Pushed by hindenburg into branch 'release/21.08'.

Resize lines when clearing to end of line.

clearImage() just clears until _columns.  To prevent characters from
beyond _columns from reappearing, e.g. due to DCH (Delete CHaracters)
requests, make clearImage() resize lines when clearing to the end of
line.
(cherry picked from commit ed7fe4a2cbb8f4fc178ae83431f0190c92d39ba2)

M  +4    -0    src/Screen.cpp

https://invent.kde.org/utilities/konsole/commit/7e0d300c2d08e8429b0e1997d07ce543c186767d