Comments (7)
Agreed. But I'll have it error out instead, pending an actual fix. Silent failures aren't acceptable either.
from ksh.
@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):
Line 420 in 9751174
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.
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.
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.
For the moment the patch to xec.c needs to be reverted, as regressions aren't acceptable.
from ksh.
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.
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)
- printf with %d: the man page should say that when ".." is used, the precision is 1 HOT 1
- RFE: meson build HOT 4
- getopts: not setting OPTARG when argument is both long form and declared optional HOT 4
- Got a "Memory fault" when trying to sum up to 1.000.000 using a recursive impl. of Gauss' algorithm HOT 2
- trap execution alters $? HOT 2
- Regression. Non determinsitic QA cycle (race condition) HOT 8
- parser confusions with braces inside ${ cmd; } form of command substitution HOT 1
- getopts OPTIND cf. OPTARG in functions
- free(): invalid pointer crash in path_pwd HOT 6
- stack overflow if cannot unlink $HOME/.sh_history HOT 1
- Negative integer literal with radix symbol should be formatted as positive with unary minus for integers defined with an explicit base. HOT 5
- 1.0.8: tons of compile time warnings. HOT 21
- nameref iteration problem HOT 5
- New `$SRANDOM` feature uses a set seed on Cygwin HOT 7
- NetBSD, DragonFlyBSD and illumos now fail to build without manually passing `LDFLAGS=-lm` HOT 7
- Build error on Kali Linux w/ 1afa0075 HOT 8
- Regression test failure @32950afe w/ macOS 12.7.3 (Intel or ARM) HOT 16
- Segfault on startup in NetBSD and DragonFlyBSD single user mode HOT 1
- builtin printf: null in format string skips input HOT 15
- echo doesn't work in namespaces (and other UNIVERSE handling oddities) HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ksh.