1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/tests
Martijn Dekker e072e7c170 Fix crash in xtrace while processing here-document (re: d7cada7b)
Depending on the OS, the heredoc.sh regression tests, and possibly
others, still crashed with the -x option (xtrace) on.

Analysis: The lexer crashes in lex_advance(). Something has caused
an inconsistent lexer state, and it happened earlier on, so the
backtrace is useless for figuring out where that happened.

But I think I've found it. It's the sh_mactry() call here:

src/cmd/ksh93/sh/xec.c, lines 2800 to 2807 in f7213f03
2800:   if(!(cp=nv_getval(sh_scoped(shp,PS4NOD))))
2801:           cp = "+ ";
2802:   else
2803:   {
2804:           sh_offoption(SH_XTRACE);
2805:           cp = sh_mactry(shp,cp);
2806:           sh_onoption(SH_XTRACE);
2807:   }

sh_mactry() needs to parse the contents of $PS4 to perform
expansions and command substitutions in it, which involves the
lexer. If that happens in a here-document, the lexer is in the C
function call stack, in the middle of parsing the here-document.
Result: inconsistent lexer state. Solution: save and restore lexer
state in sh_mactry().

After this commit, all regression tests should pass with the
'-x'/'--xtrace' option in use, with no errors or crashes.

Note for backporters: this fix depends both on on d7cada7b and on
the consistency fix for the Lex_t type's size applied in a7ed5d9f.

src/cmd/ksh93/include/shlex.h:
- Cosmetic fix: remove a copied & pasted backslash. (re: a7ed5d9f)

src/cmd/ksh93/sh/macro.c: sh_mactry():
- Save and restore the lexer state before letting sh_mactrim()
  indirectly parse and execute code.

src/cmd/ksh93/tests/*.sh:
- Turn off xtrace in various command substitutions that contain
  2>&1 redirections, so that the xtrace output is not caught by
  the command substitutions, causing tests to fail incorrectly.
- Turn off xtrace for a few code blocks with 2>&1 redirections,
  stopping xtrace output from being written to standard output.

Resolves: https://github.com/ksh93/ksh/issues/306 (again)
2021-12-27 04:02:25 +00:00
..
_common Fix xtrace (shtests -x) for the regression tests 2021-05-14 19:56:11 +02:00
alias.sh Fix multiple bugs when using 'alias -p' to print aliases (#398) 2021-12-27 03:49:06 +00:00
append.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
arith.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
arrays.sh Fix various compiler warnings and minor issues (#362) 2021-12-09 06:42:59 +01:00
arrays2.sh nv_associative(): finally use proper check for enum (re: b98e32fc) 2021-11-24 02:06:08 +01:00
attributes.sh Fix xtrace (shtests -x) for the regression tests 2021-05-14 19:56:11 +02:00
basic.sh Minor improvements to the regression tests (#366) 2021-12-09 06:43:39 +01:00
bracket.sh Backport ksh93v- bugfix for [[ 1<2 ]] (#380) 2021-12-17 03:26:41 +01:00
builtins.sh Fix yet more minor bugs related to the regression tests (#389) 2021-12-21 08:01:00 +00:00
case.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
comvar.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
comvario.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
coprocess.sh Various minor capitalization and typo fixes (#371) 2021-12-13 01:49:42 +01:00
cubetype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
enum.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
exit.sh Fix shell exit on function call redirection error (re: 23f2e23) 2021-05-19 06:59:18 +02:00
expand.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
functions.sh Various minor capitalization and typo fixes (#371) 2021-12-13 01:49:42 +01:00
glob.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
grep.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
heredoc.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
io.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
jobs.sh ...and now make it work with shcomp (re: aed5c6d7) 2021-03-13 19:27:15 +00:00
leaks.sh Release 1.0.0-beta.2 2021-12-17 04:20:04 +01:00
locale.sh more regression test updates (re: 7cdb01f6) 2021-12-16 11:46:17 +01:00
math.sh Fix xtrace (shtests -x) for the regression tests 2021-05-14 19:56:11 +02:00
nameref.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
namespace.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
options.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
path.sh tests/path.sh: update regression test (re: 7cdb01f6) 2021-12-16 09:20:00 +01:00
pointtype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
pty.sh Do not exit shell on Ctrl+C with SIGINT ignored (re: 7e5fd3e9) 2021-12-16 19:56:46 +01:00
quoting.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
quoting2.sh Fix remaining bug in ${var:-'{}'} (re: d087b031) 2021-05-03 03:14:30 +01:00
readcsv.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
readonly.sh Adjust readonly regression tests for freezes (#267) 2021-04-11 19:57:40 +01:00
recttype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
restricted.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
return.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
select.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
shtests shtests --posix: ensure consistent locale: unset all LC_* vars 2021-12-27 03:48:27 +00:00
sigchld.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
signal.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
statics.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
subshell.sh Fix various compiler warnings and minor issues (#362) 2021-12-09 06:42:59 +01:00
substring.sh Minor improvements to the regression tests (#366) 2021-12-09 06:43:39 +01:00
tilde.sh Revert "[1.0 release prep] Remove tilde expansion discipline" 2021-12-09 07:31:37 +01:00
timetype.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
treemove.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
types.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
variables.sh Fix crash in xtrace while processing here-document (re: d7cada7b) 2021-12-27 04:02:25 +00:00
vartree1.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
vartree2.sh Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00