mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
Applying the fix for 'unset -f' exposed a crashing bug in lookup()
in sh/nvdisc.c, which is the function for looking up discipline
functions. This is what caused tests/variables.sh to crash.
Ref.: https://github.com/ksh93/ksh/issues/23#issuecomment-645699614
src/cmd/ksh93/sh/nvdisc.c: lookup():
- To avoid segfault, check that the function pointer nq->nvalue.rp
is actually set before checking if nq->nvalue.rp->running==1.
src/cmd/ksh93/sh/xec.c,
src/cmd/ksh93/tests/functions.sh:
- Uncomment the 'unset -f' fix from b7932e87
.
Resolves #21 (again).
This commit is contained in:
parent
975117485c
commit
3e3f6b0f12
4 changed files with 9 additions and 8 deletions
8
NEWS
8
NEWS
|
@ -3,6 +3,14 @@ For full details, see the git log at: https://github.com/ksh93/ksh
|
||||||
|
|
||||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
|
|
||||||
|
2020-06-17:
|
||||||
|
|
||||||
|
- A bug in 'unset -f' was fixed that prevented shell functions from
|
||||||
|
unsetting themselves while they were running. A POSIX function no longer
|
||||||
|
crashes when doing so, and a KornShell-style function no longer silently
|
||||||
|
ignores an 'unset -f' on itself. A function of either form now continues
|
||||||
|
running after unsetting itself, and is removed at the end of the run.
|
||||||
|
|
||||||
2020-06-16:
|
2020-06-16:
|
||||||
|
|
||||||
- Passing the '-d' flag to the read builtin will no longer cause the '-r'
|
- Passing the '-d' flag to the read builtin will no longer cause the '-r'
|
||||||
|
|
|
@ -417,7 +417,7 @@ static char* lookup(Namval_t *np, int type, Sfdouble_t *dp,Namfun_t *handle)
|
||||||
}
|
}
|
||||||
if(bp== &block)
|
if(bp== &block)
|
||||||
block_done(bp);
|
block_done(bp);
|
||||||
if(nq && nq->nvalue.rp->running==1)
|
if(nq && nq->nvalue.rp && nq->nvalue.rp->running==1)
|
||||||
{
|
{
|
||||||
nq->nvalue.rp->running=0;
|
nq->nvalue.rp->running=0;
|
||||||
_nv_unset(nq,0);
|
_nv_unset(nq,0);
|
||||||
|
|
|
@ -3505,16 +3505,11 @@ 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);
|
nv_putval(SH_PATHNAMENOD,shp->st.filename,NV_NOFREE);
|
||||||
shp->pipepid = pipepid;
|
shp->pipepid = pipepid;
|
||||||
np->nvalue.rp->running -= 2;
|
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)
|
if(np->nvalue.rp && np->nvalue.rp->running==1)
|
||||||
{
|
{
|
||||||
np->nvalue.rp->running = 0;
|
np->nvalue.rp->running = 0;
|
||||||
_nv_unset(np, NV_RDONLY);
|
_nv_unset(np, NV_RDONLY);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1253,12 +1253,10 @@ expect_status=0
|
||||||
# When a function unsets itself, it should not fail to be unset
|
# 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; 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'
|
$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
|
$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'
|
[[ $? != 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
|
$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'
|
[[ $? != 127 ]] && err_exit 'unset of ksh function fails when it is still running'
|
||||||
end_disabled
|
|
||||||
|
|
||||||
# ======
|
# ======
|
||||||
exit $((Errors<125?Errors:125))
|
exit $((Errors<125?Errors:125))
|
||||||
|
|
Loading…
Reference in a new issue