1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

Part revert #22 to undo memory fault (re: b7932e87)

The fix in sh/xec.c, which was backported from the ksh 93v- beta to
delay the actual removal of a running function that unsets itself,
caused a segfault in the variables.sh regression tests (see #23).

src/cmd/ksh93/sh/xec.c:
- Comment out the backported code pending a correct fix for #21.
  Now both types of functions silently fail to unset themselves
  (unless they're discipline functions).

src/cmd/ksh93/tests/functions.sh:
- Disable regression tests checking that the function was actually
  unset, pending a correct fix for #21.

Resolves: #23
Reopens: #21
This commit is contained in:
Martijn Dekker 2020-06-17 21:01:55 +02:00
parent b7932e87b6
commit 975117485c
3 changed files with 7 additions and 9 deletions

9
NEWS
View file

@ -3,15 +3,6 @@ For full details, see the git log at: https://github.com/ksh93/ksh
Any uppercase BUG_* names are modernish shell bug IDs.
2020-06-17:
- A POSIX function that unsets itself while it is running no longer causes
a segmentation fault.
- `unset -f` no longer silently fails when a KornShell style function tries
to unset itself while it is running. The function will now be unset once
it has finished running.
2020-06-16:
- Passing the '-d' flag to the read builtin will no longer cause the '-r'

View file

@ -3505,11 +3505,16 @@ static void sh_funct(Shell_t *shp,Namval_t *np,int argn, char *argv[],struct arg
nv_putval(SH_PATHNAMENOD,shp->st.filename,NV_NOFREE);
shp->pipepid = pipepid;
np->nvalue.rp->running -= 2;
/*
* TODO: fix https://github.com/ksh93/ksh/issues/21
* Following causes a memory fault in: bin/shtests -p variables
*
if(np->nvalue.rp && np->nvalue.rp->running==1)
{
np->nvalue.rp->running = 0;
_nv_unset(np, NV_RDONLY);
}
*/
}
/*

View file

@ -1253,10 +1253,12 @@ expect_status=0
# When a function unsets itself, it should not fail to be unset
$SHELL -c 'PATH=/dev/null; fn() { unset -f fn; true; }; fn' || err_exit 'unset of POSIX function in the calling stack fails'
$SHELL -c 'PATH=/dev/null; function ftest { ftest2; }; function ftest2 { unset -f ftest; }; ftest' || err_exit 'unset of ksh function in the calling stack fails'
: <<\end_disabled # TODO: re-enable when https://github.com/ksh93/ksh/issues/21 is fixed
$SHELL -c 'PATH=/dev/null; fn() { unset -f fn; true; }; fn; fn' 2> /dev/null
[[ $? != 127 ]] && err_exit 'unset of POSIX function fails when it is still running'
$SHELL -c 'PATH=/dev/null; function fn { unset -f fn; true; }; fn; fn' 2> /dev/null
[[ $? != 127 ]] && err_exit 'unset of ksh function fails when it is still running'
end_disabled
# ======
exit $((Errors<125?Errors:125))