#51 Another screen-resize bug

open
Mark Hessling
None
5
2004-07-15
2004-06-21
Ian Collier
No

On Fedora Core 2, resizing the screen causes (the tty
version of) THE to crash with an arithmetic exception.
This is partly down to ncurses not checking the inputs
to the resize_term function (about which I have
notified the maintainer separately). However, when the
screen size changes, THE calls resize_term(0,0) which -
according to the documentation - is not allowed (and
has never been allowed in ncurses). In fact it seems
that if you just call endwin() and initscr() then
ncurses will resize the terminal anyway (which is why
it worked on Red Hat 7.3, where resize_term(0,0) just
returned an error).

Discussion

  • Ian Collier
    Ian Collier
    2004-06-22

     
    Attachments
  • Ian Collier
    Ian Collier
    2004-06-22

    Logged In: YES
    user_id=22883

    I'm attaching a patch which seems to fix the resize issues
    on Fedora. (I don't know whether it will break other
    systems but it does at least work on Red Hat 7.3.) The
    patch does the following.

    show.c:
    - don't call both resize_term and resizeterm
    - don't call ncurses resizeterm with zero arguments
    - don't call initscr (the definition allows it to be called
    only once, during initialisation off the application)

    the.c:
    - allow SIGWINCH to interrupt keyboard reads so that you
    don't have to press a key after resizing the window

    getch.c:
    - this is a horrible hack to prevent THE from saying
    "invalid operand" when the screen size changes. This should
    preferably be fixed properly, by teaching THE's keyboard
    handler how to handle error returns from wgetch(). At least
    one bug still remains (whatever was on the command line
    before the resize disappears although it will still be
    executed when you press the return key).

    Note that modern versions of ncurses supply their own
    SIGWINCH handler if you don't override it - there's a good
    case for using this, but it would have to be handled by
    making THE deal appropriately with KEY_RESIZE events
    received from wgetch().

     
  • Mark Hessling
    Mark Hessling
    2004-07-15

    • assigned_to: nobody --> rexx
     
  • Logged In: YES
    user_id=368139

    Just noting that Ian's patch also works for the 3.2b1 with a
    minor change in the show.c section,

    #if defined(SIGWINCH) && defined(USE_NCURSES) &&
    defined(HAVE_RESIZETERM)

    is in 3.2b1 instead of

    #if defined(SIGWINCH) && defined(USE_NCURSES)

    present in 3.1

    I have also observed segfaults both in the-ncurses and in
    the-xcurses when resizing to a size where no row or column
    fits into the box, that is when the number of either columns
    or rows into the box is 0