• Bug#265631: libncurses5: race condition between setting up default SIGW

    From Marc Lehmann@1:229/2 to All on Sat Aug 14 07:30:09 2004
    From: [email protected]

    Package: libncurses5
    Version: 5.4-4
    Severity: normal

    While investigating debian bug #202497 and reading pages such as http://wiki.ael.be/ion/index.php/FrequentlyAskedQuestions, I took a look
    at libncurses, which many programs that misbehave use.

    The problem is that libncurses sets up a (helpful) SIGWINCH handler, but
    it does so only _after_ fetching the screen size using TIOCGWINSZ.

    This effectively creates a race condition: if the program receives a
    SIGWINCH after TIOCGWINSZ but before it installs a SIGWINCH handler, the
    resize will go undetected.

    The reason why this is seen rarely in practise is manyfold:

    1. many (but not all) terminal emulators use various tricks to get
    around these problems. xterm re-sets the window size on the first refresh,
    beta versions of rxvt do the same upon receiving the first line of
    program output. In the worst case this leads to two resizes, which
    is harmless, but still the workaround punishes correctly written programs
    and forces terminal emulators to implement hacks.

    2. this only happens when the window is resized quickly after opening. in
    most cases (window manager doesn't forcefully resize or the window fits
    on the screen), this does not happen. But many window managers resize
    geometries that wouldn't fit on the screen, and some basically always
    resize (e.g. ion). In these cases the problem happens frequently (jed
    under rxvt-unicode under ion gets the initial screensize wrong about
    every 3rd time on my system. sending a sigwinch works around this issue).

    3. earlier xterm and rxvt (+clones) releases had a different race
    condition where the child and the parent set the window size, and
    depending on who runs first, the outcome was unpredictable. This is a
    difefrent bug, though.

    The fix (for ncurses) would be to set the signal handler before using TIOCGWINSZ. This should have no effect on correctly-written programs (such
    as mutt), but will automatically fix most curses users who do not install
    their own sigwinch handler, or do so very late.

    -- System Information:
    Debian Release: 3.1
    APT prefers testing
    APT policy: (700, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: i386 (i686)
    Kernel: Linux 2.6.6
    Locale: LANG=C, LC_CTYPE=de_DE.UTF-8

    Versions of packages libncurses5 depends on:
    hi libc6 2.3.2.ds1-11 GNU C Library: Shared libraries an

    -- no debconf information


    --
    To UNSUBSCRIBE, email to [email protected]
    with a subject of "unsubscribe". Trouble? Contact [email protected]

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