From e58637752abe9b5a87e451a8fadc664e2a36a6f5 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Mon, 8 Mar 2021 20:49:02 +0000 Subject: [PATCH] sh_debug(): restore NV_NOFREE attributes (re: c928046a) Removing the nv_putval() calls also stopped making sure the NV_NOFREE attribute was set for those variables, causing an invalid free later on. This caused the funcname.ksh script: https://gist.github.com/ormaaj/12874b68acd06ee98b59 to crash even more readily than it did before. Even after this commit there are various crashing bugs left for that script, all intermittent and with different backtraces and dependent on the operating system and malloc variant used. Investigation ongoing at: https://github.com/ksh93/ksh/issues/212 --- src/cmd/ksh93/sh/xec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index e4caa2daa..c116e3419 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -695,6 +695,8 @@ int sh_debug(Shell_t *shp, const char *trap, const char *name, const char *subsc n = sh_trap(trap,0); np->nvalue.cp = 0; shp->indebug = 0; + nv_onattr(SH_PATHNAMENOD,NV_NOFREE); + nv_onattr(SH_FUNNAMENOD,NV_NOFREE); if(shp->st.cmdname) error_info.id = shp->st.cmdname; shp->st = savst;