Code Monkey home page Code Monkey logo

Comments (7)

McDutchie avatar McDutchie commented on August 18, 2024 1

Agreed. But I'll have it error out instead, pending an actual fix. Silent failures aren't acceptable either.

from ksh.

McDutchie avatar McDutchie commented on August 18, 2024 1

@JohnoKing, I found the cause of the crash.

As my backtrace showed, it was indeed in lookup(), which is the function for looking up a variable's discipline function (which makes sense of where the regression test crash occurred):

if(nq && nq->nvalue.rp->running==1)

That line fails to check whether nq->nvalue.rp is even a valid pointer before querying nq->nvalue.rp->running, and if it isn't, that's an instant segfault. And it makes complete sense that this pointer would be zero'd after calling _nv_unset in the backported fix.

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.

from ksh.

JohnoKing avatar JohnoKing commented on August 18, 2024

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);
+	}
 }
 
 /*

from ksh.

McDutchie avatar McDutchie commented on August 18, 2024

Interesting. If you comment out just the _nv_unset(np, NV_RDONLY); and leave the rest, then the memory fault disappears but you get funny regression test failures in variables.sh, as well as two expected ones in functions.sh:

test functions begins at 2020-06-17+20:02:15
	functions.sh[1270]: unset of POSIX function fails when it is still running
	functions.sh[1272]: unset of ksh function fails when it is still running
test functions failed at 2020-06-17+20:02:18 with exit code 2 [ 113 tests 2 errors ]
[...]
test variables begins at 2020-06-17+20:03:18
	variables.sh[193]: foo.get discipline not working after unset
	variables.sh[205]: $@ not equal to ${@}
	variables.sh[205]: $* not equal to ${*}
	variables.sh[205]: $! not equal to ${!}
	variables.sh[209]: ${!%?} not correct
	variables.sh[213]: ${!#?} not correct
	variables.sh[205]: $# not equal to ${#}
	variables.sh[209]: ${#%?} not correct
	variables.sh[213]: ${##?} not correct
	variables.sh[218]: ${##} not correct
	variables.sh[205]: $- not equal to ${-}
	variables.sh[209]: ${-%?} not correct
	variables.sh[213]: ${-#?} not correct
	variables.sh[218]: ${#-} not correct
	variables.sh[205]: $? not equal to ${?}
	variables.sh[209]: ${?%?} not correct
	variables.sh[213]: ${?#?} not correct
	variables.sh[218]: ${#?} not correct
	variables.sh[205]: $$ not equal to ${$}
	variables.sh[209]: ${$%?} not correct
	variables.sh[213]: ${$#?} not correct
test variables failed at 2020-06-17+20:03:20 with exit code 21 [ 125 tests 21 errors ]

from ksh.

JohnoKing avatar JohnoKing commented on August 18, 2024

For the moment the patch to xec.c needs to be reverted, as regressions aren't acceptable.

from ksh.

McDutchie avatar McDutchie commented on August 18, 2024

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

from ksh.

McDutchie avatar McDutchie commented on August 18, 2024

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.

from ksh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.