-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory fault in tests/variables.sh #23
Comments
It looks like it was this change that caused it: diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c
index 6bb4355..1a0428c 100644
--- a/src/cmd/ksh93/sh/xec.c
+++ b/src/cmd/ksh93/sh/xec.c
@@ -3505,11 +3505,6 @@ 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;
+ if(np->nvalue.rp && np->nvalue.rp->running==1)
+ {
+ np->nvalue.rp->running = 0;
+ _nv_unset(np, NV_RDONLY);
+ }
}
/* |
Interesting. If you comment out just the
|
For the moment the patch to xec.c needs to be reverted, as regressions aren't acceptable. |
Agreed. But I'll have it error out instead, pending an actual fix. Silent failures aren't acceptable either. |
It is more complicated than I thought. For instance, this bit from tests/variables.sh was working, and should not error out now: unset -n foo
foo=junk
function foo.get
{
.sh.value=stuff
unset -f foo.get
}
if [[ $foo != stuff ]]
then err_exit "foo.get discipline not working"
fi
if [[ $foo != junk ]]
then err_exit "foo.get discipline not working after unset"
fi |
I have been unable to implement an error message without also making it impossible for discipline functions to unset themselves, something that used to work. So I'll have to restore old behaviour for now. The segfault stays fixed, but now both types of functions silently fail to unset themselves. :-/ I'll reopen #21 to deal with that. |
@JohnoKing, I found the cause of the crash. As my backtrace showed, it was indeed in Line 420 in 9751174
That line fails to check whether In ksh 93v-, that line was changed to: if(nq && nq->nvalue.rp && nq->nvalue.rp->running==1) Applying that along with reapplying the reverted fix, fixes everything. A commit is on the way. |
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.: #23 (comment) 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 b7932e8. Resolves #21 (again).
Attn: @JohnoKing
I may have been too quick in merging #22. On my system, that commit introduced a memory fault in one of the regression tests in variables.c:
Here is the backtrace from
lldb
:It makes little sense to me. Why SIGSTOP when it was killed by SIGSEGV?
The text was updated successfully, but these errors were encountered: