[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: psql: Buggy interactions with wraparound in maximized gnome terminal

From: Chet Ramey
Subject: Re: psql: Buggy interactions with wraparound in maximized gnome terminals.
Date: Sat, 21 Dec 2019 15:31:46 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.3.1

On 12/20/19 4:48 PM, Tomas Zubiri wrote:
> Ok, makes sense. Since psql depends on readline, I'm adding their bug
> mailing list to the loop, and reposting the original bug report:
> This is probably hard to reproduce, but I entered a state where the
> command I was writing was wrapping around at the 81st character while
> in full screen,  and the 1st character was being overwritten.This did
> not affect the command sent to the server, but I would not have a way
> to see what command I just entered.

It seems like the readline SIGWINCH handler, which causes it to update its
idea of the screen dimensions, isn't being called. I can't reproduce this
using readline and bash, and I don't know what postgres does with its
signal handling, or how it configures readline's signal handling (I assume
it doesn't do anything special).

I'll look at little more at something that doesn't modify the readline
signal handling defaults and see if I can reproduce it.

> I'm using ubuntu 18.04, the terminal is Gnome Terminal 3.28.2
> Below is a short video showcasing the issue.  I thought I had muted my
> mic, but apparently I didn't, please enjoy my nation's anthem while
> observing said bug.

I did enjoy it. :-)

> https://drive.google.com/file/d/1Xdj96v2StfM9E7HuM5NOsnOVssjw5fcg/view?usp=drive_web
> Additionally, while researching this bug, I found a reproducible
> variation of this bug:
> 1- Open a terminal at a normal size.
> 2- Write enough characters so that they correctly wrap around into a new line.
> 3- Maximize the window
> 4- Minimize it again
> You will find that the command is visibly duplicated. Again this is
> aesthetic, the command is not duplicated when it's sent to the server.

This one's easy to explain. By the time readline's SIGWINCH handler is
called, the terminal has already wrapped and redisplayed the text, leaving
the cursor at the end of the text on the second line.

Readline has no way of knowing this, and performs a full redisplay. This
involves moving to column 0 of what it thinks is the first screen line of
the current line being entered (it thinks that is line 0, since it doesn't
know what the terminal has done and, as far as it knows, the line isn't
wrapped), clearing the line, and performing a full redisplay including
reprinting the prompt. That obviously leaves the other lines, the ones the
terminal wrapped before sending SIGWINCH, visible on the screen.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]