• Bug#265552: pstree indentation doesn't line up in xterm (1/2)

    From Joey Hess@1:229/2 to All on Fri Aug 13 21:00:13 2004
    XPost: linux.debian.maint.x
    From: [email protected]

    --sm4nu43k4a2Rpi4c
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Package: xterm
    Version: 4.3.0.dfsg.1-6
    Severity: normal

    The pstree command outputs a process tree, and on a capable terminal
    such as xterm it will use some kind of escape sequences to display line
    drawing characters(?). It seems that this sometimes confuses xterm
    leading to display glitches. Let me try to paste in what I'm seeing:

    tqxdmqwqXFree86-debug
    x mqxdmqqq.xsessionqwqionqwqfirefo+
    x x tqxchatqqqxchat+
    x x tqxmmsqqqxmms
    x x tqxtermqqqzsh
    x x tqxtermqqqzsh
    x x tq3*[xtermqqqzs+
    x x tqxtermqqqzsh
    x x tqxtermqqqzsh
    x x tqxtermqqqzsh
    x x mqxtermqqqzsh
    x tqprocmeter3
    x tqssh-agent

    Well, it lost the line drawing characters, but you can see some of the x's don't line up. Here's how it is intended to look, from pstree ran with TERM=dumb:

    |-xdm-+-XFree86-debug
    | `-xdm---.xsession-+-ion-+-firefox-bin---firefox-bin---3*[firefox-bi+
    | | |-xchat---xchat---xchat
    | | |-xmms---xmms---2*[xmms]
    | | |-xterm---zsh---tail---tail
    | | |-xterm---zsh---w3m
    | | |-xterm---zsh---mutt---editmail---vim
    | | |-4*[xterm---zsh]
    | | |-xterm---zsh---ssh
    | | `-xterm---zsh---pstree
    | |-procmeter3

    So the indentation is broken with the line drawing characters. At first I assumed this was a pstree bug, but then I straced it:

    write(1, " \33(0\17tq\33(Bxdm\33(0\17qwq\33(BXFree"..., 41 tqxdmqwqXFree86-debug
    ) = 41
    write(1, " \33(0\17x\33(B \33(0\17mq\33(Bxdm\33("..., 80 x mqxdmqqq.xsessionqwqionqwqfirefo+
    ) = 80
    write(1, " \33(0\17x\33(B "..., 80 x x tqxchatqqqxchat+
    ) = 80
    write(1, " \33(0\17x\33(B "..., 80 x x tqxmmsqqqxmms
    80
    write(1, " \33(0\17x\33(B "..., 80 x x tqxtermqqqzsh
    80
    write(1, " \33(0\17x\33(B "..., 80 x x tqxtermqqqzsh
    80
    write(1, " \33(0\17x\33(B "..., 80 x x tqxtermqqqzsh
    80
    write(1, " \33(0\17x\33(B "..., 80 x x tq3*[xtermqqqzs+
    ) = 80

    The strace shows that pstree is properly indenting the lines that do not
    diplay indented when it's not straced. Also, notice that after each write() output by strace, we see the actual result of the write, and in each case
    xterm managed this time to display the leading indentation properly.

    I sshed around to a few other systems, and pstree on those has the
    occasional missing indentation too. These systems were running various
    versions of pstree. I also tried running it in gnome-terminal, and in
    uxterm, and in both cases it displayed ok. I cleared all X resource
    setting (xrdb </dev/null; xterm) and can still reproduce the problem; I
    also tried running pstree in an xterm (4.3.0.dfsg.1-4) on another computer,
    and still saw the problem.

    I've managed to capture some pstree output to a file that seems to
    reproduce the problem when I cat it in an xterm, even an xterm on
    another machine. I've attached that file. When this file is catted,
    the result is not identical to the pstree indentation problem I
    described above; only one or two lines are displated without
    indentation. I hope it's enough to help reproduce the bug.

    --
    see shy jo

    --sm4nu43k4a2Rpi4c
    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename=pstree-output Content-Transfer-Encoding: quoted-printable


    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)
  • From Joey Hess@1:229/2 to Thomas Dickey on Sat Aug 14 03:40:06 2004
    XPost: linux.debian.maint.x
    From: [email protected]

    --NDin8bjvE/0mNLFQ
    Content-Type: text/plain; charset=us-ascii
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Thomas Dickey wrote:
    On Fri, Aug 13, 2004 at 09:00:13PM +0200, Joey Hess wrote:
    Package: xterm
    Version: 4.3.0.dfsg.1-6
    Severity: normal

    that's xterm 191?

    e.g., output from
    xterm -v

    It's 190.

    The pstree command outputs a process tree, and on a capable terminal
    such as xterm it will use some kind of escape sequences to display line drawing characters(?). It seems that this sometimes confuses xterm
    leading to display glitches. Let me try to paste in what I'm seeing:

    "sometimes"(?)
    - I don't see this behavior when I'm looking for it.
    (I saw the previous posting wrt this problem).

    I've very confused by the way I see one thing if I run pstree straight,
    and another thing if I redirect its output to a file and cat it. Also,
    which lines lack indentation seem to vary by what's in my process tree;
    for example right now, only one line of my pstree output is
    mis-indented, while there were many when I sent the bug.

    much of the posting is relatively simple. However -

    So the indentation is broken with the line drawing characters. At first I assumed this was a pstree bug, but then I straced it:

    write(1, " \33(0\17tq\33(Bxdm\33(0\17qwq\33(BXFree"..., 41 tqxdmqwqXFree86-debug) = 41
    write(1, " \33(0\17x\33(B \33(0\17mq\33(Bxdm\33("..., 80 x mqxdmqqq.xsessionqwqionqwqfirefo+) = 80
    ^^^^^^^^^^^^^^
    This caught my eye though. It doesn't correspond to one of the terminal descriptions in ncurses. Checking the source (psmisc), I see that it's
    using hardcoded escape sequences in combination with some termcap features. It also has some hardcoded behavior which would make it produce garbage
    for ISO-8859-1 text, since it assumes that it must be UTF-8. (I'm
    looking at the out_char function in pstree.c). That makes it look like
    a problem in psmisc rather than xterm.

    It's surely evil code, see bug #265553.

    The strace shows that pstree is properly indenting the lines that do not

    I'm not certain about "properly" unless I take the whole thing apart.
    I'll look at the typescript (though it seemed mangled by the newsreader).

    By "properly" I meant only that each line is indented with a seemingly appropriate number of spaces, even though xterm does not always display the leading spaces.

    A typescript is a good idea. I've attached one taken with script. When
    I did this, and when I play this typescript back with cat, the only line
    that is mis-indented is the "xmms" one.

    (Note that I use hard-coded escape sequences in my shell's prompt; those
    arn't the fault of pstree, but they seem unrelated to this bug.)

    diplay indented when it's not straced. Also, notice that after each write() output by strace, we see the actual result of the write, and in each case xterm managed this time to display the leading indentation properly.

    I sshed around to a few other systems, and pstree on those has the occasional missing indentation too. These systems were running various versions of pstree. I also tried running it in gnome-terminal, and in uxterm, and in both cases it displayed ok. I cleared all X resource

    But when you're running in xterm, what locale?

    I don't see the $TERM and locale variables which are in use - those
    are relevant.

    joey@dragon:~>locale
    LANG=en_US
    LC_CTYPE="en_US"
    LC_NUMERIC="en_US"
    LC_TIME=C
    LC_COLLATE=C
    LC_MONETARY="en_US"
    LC_MESSAGES="en_US"
    LC_PAPER="en_US"
    LC_NAME="en_US"
    LC_ADDRESS="en_US"
    LC_TELEPHONE="en_US"
    LC_MEASUREMENT="en_US"
    LC_IDENTIFICATION="en_US"
    LC_ALL=

    joey@dragon:~>echo $TERM
    xterm

    I'm using the stock debian xterm terminfo file BTW, though I suspect
    pstree does not even use it.

    --
    see shy jo

    --NDin8bjvE/0mNLFQ
    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename=typescript
    Content-Transfer-Encoding: quoted-printable


    [continued in next message]

    --- SoupGate-Win32 v1.05
    * Origin: you cannot sedate... all the things you hate (1:229/2)