Re: psql: Buggy interactions with wraparound in maximized gnome terminals.

From: Chet Ramey <chet(dot)ramey(at)case(dot)edu>
To: Tomas Zubiri <me(at)tomaszubiri(dot)com>, bug-readline(at)gnu(dot)org
Cc: chet(dot)ramey(at)case(dot)edu, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: psql: Buggy interactions with wraparound in maximized gnome terminals.
Date: 2019-12-21 20:31:46
Message-ID: ad87818d-d05b-e8c8-224d-587011e2ac29@case.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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.

Chet

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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-12-21 21:40:29 Re: psql: Buggy interactions with wraparound in maximized gnome terminals.
Previous Message Bruce Momjian 2019-12-21 18:00:06 Re: BUG #16151: startup timing problem