[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BUG: bash-4.0.17 and SIGWINCH during initialization
From: |
Chet Ramey |
Subject: |
Re: BUG: bash-4.0.17 and SIGWINCH during initialization |
Date: |
Mon, 13 Apr 2009 17:48:57 -0400 |
User-agent: |
Thunderbird 2.0.0.21 (Macintosh/20090302) |
Nicolai Lissner wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
> -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -march=athlon64 -O2
> -pipe -fPIC
> uname output: Linux lilith 2.6.29.1 #1 PREEMPT Fri Apr 3 03:32:29 CEST 2009
> x86_64 AMD Athlon(tm) Processor LE-1620 AuthenticAMD GNU/Linux
> Machine Type: x86_64-unknown-linux-gnu
>
> Bash Version: 4.0
> Patch Level: 17
> Release Status: release
>
> Description:
>
> There is some kind of race condition in bash-4
> (or maybe even readline) when it receives SIGWINCH
> during initialization.
Not a race condition exactly, but a timing issue. The problem occurs
when a SIGWINCH arrives during redisplay. The SIGWINCH handler tries
to update the display immediately to reflect the new window size, but
steps on itself when calling the redisplay code recursively. A simple
semaphore is enough to prevent the double calls.
Try the attached patch and let me know how it works.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.0-patched/lib/readline/readline.h 2009-01-04 14:32:33.000000000
-0500
--- lib/readline/readline.h 2009-04-13 08:47:00.000000000 -0400
***************
*** 815,820 ****
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command
*/
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at
least once */
! #define RL_STATE_DONE 0x800000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
--- 815,821 ----
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command
*/
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at
least once */
+ #define RL_STATE_REDISPLAYING 0x800000 /* updating terminal display */
! #define RL_STATE_DONE 0x1000000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
*** ../bash-4.0-patched/lib/readline/display.c 2009-01-04 14:32:32.000000000
-0500
--- lib/readline/display.c 2009-04-13 08:29:54.000000000 -0400
***************
*** 513,516 ****
--- 513,517 ----
data structures. */
_rl_block_sigint ();
+ RL_SETSTATE (RL_STATE_REDISPLAYING);
if (!rl_display_prompt)
***************
*** 1237,1240 ****
--- 1238,1242 ----
}
+ RL_UNSETSTATE (RL_STATE_REDISPLAYING);
_rl_release_sigint ();
}
*** ../bash-4.0-patched/lib/readline/terminal.c 2009-01-04 14:32:34.000000000
-0500
--- lib/readline/terminal.c 2009-04-13 08:43:00.000000000 -0400
***************
*** 356,360 ****
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
! else
_rl_redisplay_after_sigwinch ();
}
--- 356,360 ----
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
! else if (RL_ISSTATE(RL_STATE_REDISPLAYING) == 0)
_rl_redisplay_after_sigwinch ();
}