diff options
| author | Chet Ramey <chet.ramey@case.edu> | 2022-11-21 11:43:19 -0500 |
|---|---|---|
| committer | Chet Ramey <chet.ramey@case.edu> | 2022-11-21 11:43:19 -0500 |
| commit | 94d25f57f124a9b2268a3af0a0915871032f426e (patch) | |
| tree | 7f561e25d6ba728881d33e2b108a724b7de34c60 | |
| parent | 407d9afca046256d664becb70fd85b948d6c3450 (diff) | |
| download | bash-94d25f57f124a9b2268a3af0a0915871032f426e.tar.gz | |
fix for too-aggressive optimizing forks away in an `eval' command inside a (command) subshell
| -rw-r--r-- | CWRU/CWRU.chlog | 29 | ||||
| -rw-r--r-- | builtins/common.h | 1 | ||||
| -rw-r--r-- | builtins/eval.def | 2 | ||||
| -rw-r--r-- | builtins/evalstring.c | 9 | ||||
| -rw-r--r-- | doc/bashref.texi | 10 | ||||
| -rw-r--r-- | doc/version.texi | 6 | ||||
| -rw-r--r-- | jobs.c | 2 | ||||
| -rw-r--r-- | lib/readline/readline.c | 5 | ||||
| -rw-r--r-- | parse.y | 2 | ||||
| -rw-r--r-- | trap.c | 6 |
10 files changed, 52 insertions, 20 deletions
diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 94ed6c4..ba9d673 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -4466,3 +4466,32 @@ lib/glob/sm_loop.c Updates from Koichi Murase <myoga.murase@gmail.com> - BRACKMATCH: if a range expression is incomplete (no end char), treat the bracket as an ordinary character + + 11/18 + ----- +doc/bashref.texi + - Reporting Bugs: add mention of the Savannah project page. Suggested + by Loïc Yhuel <loic.yhuel@gmail.com> + + 11/20 + ----- +builtins/common.h + - SEVAL_NOOPTIMIZE: new flag for parse_and_execute: means don't try to + optimize forks out of any simple or conditional commands + +builtins/evalstring.c + - parse_and_execute: if FLAGS includes SEVAL_NOOPTIMIZE, don't try to + call can_optimize_connection to optimize away forks from AND_AND or + OR_OR commands + +builtins/eval.def,trap.c,parse.y,jobs.c + - parse_and_execute: include SEVAL_NOOPTIMIZE in any calls to + parse_and_execute. Fixes bug reported by + Frode Nordahl <frode.nordahl@canonical.com> + + 11/21 + ----- +lib/readline/readline.c + - readline_initialize_everything: use xmalloc to initialize + rl_executing_keyseq, since we use xrealloc to reallocate it and + don't check it for NULL anywhere diff --git a/builtins/common.h b/builtins/common.h index 726bd91..a170f8f 100644 --- a/builtins/common.h +++ b/builtins/common.h @@ -51,6 +51,7 @@ do { \ #define SEVAL_FUNCDEF 0x080 /* only allow function definitions */ #define SEVAL_ONECMD 0x100 /* only allow a single command */ #define SEVAL_NOHISTEXP 0x200 /* inhibit history expansion */ +#define SEVAL_NOOPTIMIZE 0x400 /* don't try to set optimization flags */ /* Flags for describe_command, shared between type.def and command.def */ #define CDESC_ALL 0x001 /* type -a */ diff --git a/builtins/eval.def b/builtins/eval.def index a92b538..f459bce 100644 --- a/builtins/eval.def +++ b/builtins/eval.def @@ -53,5 +53,5 @@ eval_builtin (list) return (EX_USAGE); list = loptend; /* skip over possible `--' */ - return (list ? evalstring (string_list (list), "eval", SEVAL_NOHIST) : EXECUTION_SUCCESS); + return (list ? evalstring (string_list (list), "eval", SEVAL_NOHIST|SEVAL_NOOPTIMIZE) : EXECUTION_SUCCESS); } diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 30aa8c6..1bb630e 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -132,8 +132,8 @@ optimize_connection_fork (command) if (command->type == cm_connection && (command->value.Connection->connector == AND_AND || command->value.Connection->connector == OR_OR || command->value.Connection->connector == ';') && (command->value.Connection->second->flags & CMD_TRY_OPTIMIZING) && - ((startup_state == 2 && should_suppress_fork (command->value.Connection->second)) || - ((subshell_environment & SUBSHELL_PAREN) && should_optimize_fork (command->value.Connection->second, 0)))) + (should_suppress_fork (command->value.Connection->second) || + ((subshell_environment & SUBSHELL_PAREN) && should_optimize_fork (command->value.Connection->second, 0)))) { command->value.Connection->second->flags |= CMD_NO_FORK; command->value.Connection->second->value.Simple->flags |= CMD_NO_FORK; @@ -290,6 +290,7 @@ parse_prologue (string, flags, tag) (flags & SEVAL_NOFREE) -> don't free STRING when finished (flags & SEVAL_RESETLINE) -> reset line_number to 1 (flags & SEVAL_NOHISTEXP) -> history_expansion_inhibited -> 1 + (flags & SEVAL_NOOPTIMIZE) -> don't try to turn on optimizing flags */ int @@ -502,7 +503,9 @@ parse_and_execute (string, from_file, flags) if we are at the end of the command string, the last in a series of connection commands is command->value.Connection->second. */ - else if (command->type == cm_connection && can_optimize_connection (command)) + else if (command->type == cm_connection && + (flags & SEVAL_NOOPTIMIZE) == 0 && + can_optimize_connection (command)) { command->value.Connection->second->flags |= CMD_TRY_OPTIMIZING; command->value.Connection->second->value.Simple->flags |= CMD_TRY_OPTIMIZING; diff --git a/doc/bashref.texi b/doc/bashref.texi index b0dc2fa..e210647 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -2163,7 +2163,7 @@ introduce indirection. In each of the cases below, @var{word} is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion. -When not performing substring expansion, using the form described +When not performing substring expansion, using the forms described below (e.g., @samp{:-}), Bash tests for a parameter that is unset or null. Omitting the colon results in a test only for a parameter that is unset. Put another way, if the colon is included, @@ -9592,11 +9592,11 @@ The latest version of Bash is always available for FTP from @uref{http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz}. Once you have determined that a bug actually exists, use the -@code{bashbug} command to submit a bug report. -If you have a fix, you are encouraged to mail that as well! +@code{bashbug} command to submit a bug report or use the form at the +<a href="https://savannah.gnu.org/projects/bash/">Bash project page</a>. +If you have a fix, you are encouraged to submit that as well! Suggestions and `philosophical' bug reports may be mailed -to @email{bug-bash@@gnu.org} or posted to the Usenet -newsgroup @code{gnu.bash.bug}. +to @email{bug-bash@@gnu.org} or @email{help-bash@gnu.org}. All bug reports should include: @itemize @bullet diff --git a/doc/version.texi b/doc/version.texi index 175aa07..08c7a33 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2022 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Mon Sep 19 11:13:51 EDT 2022 +@set LASTCHANGE Fri Nov 18 11:09:41 EST 2022 @set EDITION 5.2 @set VERSION 5.2 -@set UPDATED 19 September 2022 -@set UPDATED-MONTH September 2022 +@set UPDATED 18 November 2022 +@set UPDATED-MONTH November 2022 @@ -4242,7 +4242,7 @@ run_sigchld_trap (nchild) jobs_list_frozen = 1; for (i = 0; i < nchild; i++) { - parse_and_execute (savestring (trap_command), "trap", SEVAL_NOHIST|SEVAL_RESETLINE); + parse_and_execute (savestring (trap_command), "trap", SEVAL_NOHIST|SEVAL_RESETLINE|SEVAL_NOOPTIMIZE); } run_unwind_frame ("SIGCHLD trap"); diff --git a/lib/readline/readline.c b/lib/readline/readline.c index b58a785..4c8a05d 100644 --- a/lib/readline/readline.c +++ b/lib/readline/readline.c @@ -1327,9 +1327,8 @@ readline_initialize_everything (void) _rl_parse_colors (); #endif - rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16); - if (rl_executing_keyseq) - rl_executing_keyseq[rl_key_sequence_length = 0] = '\0'; + rl_executing_keyseq = xmalloc (_rl_executing_keyseq_size = 16); + rl_executing_keyseq[rl_key_sequence_length = 0] = '\0'; } /* If this system allows us to look at the values of the regular @@ -2843,7 +2843,7 @@ execute_variable_command (command, vname) if (last_lastarg) last_lastarg = savestring (last_lastarg); - parse_and_execute (savestring (command), vname, SEVAL_NONINT|SEVAL_NOHIST); + parse_and_execute (savestring (command), vname, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOOPTIMIZE); restore_parser_state (&ps); bind_variable ("_", last_lastarg, 0); @@ -453,7 +453,7 @@ run_pending_traps () if (function_code == 0) /* XXX is x always last_command_exit_value? */ - x = parse_and_execute (trap_command, "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE); + x = parse_and_execute (trap_command, "trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE|SEVAL_NOOPTIMIZE); else { parse_and_execute_cleanup (sig + 1); /* XXX - could use -1 */ @@ -1017,7 +1017,7 @@ run_exit_trap () if (code == 0 && function_code == 0) { reset_parser (); - parse_and_execute (trap_command, "exit trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE); + parse_and_execute (trap_command, "exit trap", SEVAL_NONINT|SEVAL_NOHIST|SEVAL_RESETLINE|SEVAL_NOOPTIMIZE); } else if (code == ERREXIT) retval = last_command_exit_value; @@ -1130,7 +1130,7 @@ _run_trap_internal (sig, tag) function_code = setjmp_nosigs (return_catch); } - flags = SEVAL_NONINT|SEVAL_NOHIST; + flags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOOPTIMIZE; if (sig != DEBUG_TRAP && sig != RETURN_TRAP && sig != ERROR_TRAP) flags |= SEVAL_RESETLINE; if (function_code == 0) |
