On Fri, Apr 11, 2014 at 01:04:28PM +0200, Werner Fink wrote: > > with searching in the heap I see > > (gdb) find /g 0x007d3000, 0x00896000, 0x82b910 > 0x82c5e8 > 0x82cb98 > 0x82cba8 > warning: Unable to access target memory at 0x8924b0, halting search. > 3 patterns found. > (gdb) next > nv_associative (np=0x82cae0, sp=0x0, mode=<optimized out>) at > /usr/src/packages/BUILD/ksh93/src/cmd/ksh93/sh/array.c:1790 > 1790 ap->cur = 0; > (gdb) next > 1913 } > (gdb) find /g 0x007d3000, 0x00896000, 0x82b910 > 0x82c5e8 > 0x82cb98 > warning: Unable to access target memory at 0x8924a0, halting search. > 2 patterns found. > (gdb) next > array_putval (np=0x82cae0, string=0x0, flags=1, dp=<optimized out>) at > /usr/src/packages/BUILD/ksh93/src/cmd/ksh93/sh/array.c:686 > 686 np->nvalue.cp = 0; > (gdb) next > 716 if(array_elem(ap)==0 && > (ap->flags&ARRAY_SCAN)) > (gdb) next > 724 if(!mp || mp!=np || is_associative(ap)) > (gdb) next > 765 while(!string && nv_nextsub(np)); > (gdb) next > 653 int xfree = > (ap->fixed||is_associative(ap))?0:array_isbit(aq->bits,aq->cur,ARRAY_NOFREE); > (gdb) find /g 0x007d3000, 0x00896000, 0x82b910 > 0x82c5e8 > warning: Unable to access target memory at 0x895d70, halting search. > 1 pattern found. > (gdb) cont > Continuing. > > Program received signal SIGSEGV, Segmentation fault. > 0x0000000000437723 in nv_name (np=0x82c5b0) at > /usr/src/packages/BUILD/ksh93/src/cmd/ksh93/sh/name.c:3874 > 3874 if(mp && (mp->nvname==0 || *mp->nvname==0)) > > and mp is (Namval_t*)np->nvenv here > > (gdb) print (Namval_t*)np->nvenv > $42 = (Namval_t *) 0x82b910 > > ... is there a NV_REV flag missed?
OK the attached patch does avoid this trouble as well as some of already reported one. -- "Having a smoking section in a restaurant is like having a peeing section in a swimming pool." -- Edward Burr
--- src/cmd/ksh93/sh/array.c +++ src/cmd/ksh93/sh/array.c 2014-04-11 14:58:27.000000000 +0000 @@ -1782,8 +1782,8 @@ return((void*)ap); case NV_ADELETE: if(ap->cur) - { - if(!ap->header.scope || (Dt_t*)ap->header.scope==ap->header.table || !nv_search(ap->cur->nvname,(Dt_t*)ap->header.scope,0)) + { Dt_t* scope = ap->header.scope; + if(!scope || scope==ap->header.table || !nv_search(ap->cur->nvname,scope,0)) ap->header.nelem--; _nv_unset(ap->cur,NV_RDONLY); nv_delete(ap->cur,ap->header.table,0); --- src/cmd/ksh93/sh/macro.c +++ src/cmd/ksh93/sh/macro.c 2014-04-08 09:27:37.050234765 +0000 @@ -2134,7 +2134,6 @@ static void comsubst(Mac_t *mp,register if(t) { fcsave(&save); - sfclose(sp); if(t->tre.tretyp==0 && !t->com.comarg && !t->com.comset) { /* special case $(<file) and $(<#file) */ @@ -2142,6 +2141,8 @@ static void comsubst(Mac_t *mp,register int r; struct checkpt buff; struct ionod *ip=0; + if (sp) + sfclose(sp); sh_pushcontext(mp->shp,&buff,SH_JMPIO); if((ip=t->tre.treio) && ((ip->iofile&IOLSEEK) || !(ip->iofile&IOUFD)) && --- src/cmd/ksh93/sh/name.c +++ src/cmd/ksh93/sh/name.c 2014-04-07 10:06:20.150735631 +0000 @@ -947,7 +947,7 @@ if(c) *sp = c; top = 0; - if(np && !nv_isattr(np,NV_MINIMAL) && shp->oldnp && !np->nvenv && shp->oldnp!=np) + if(np && !nv_isattr(np,NV_MINIMAL) && shp->oldnp && !np->nvenv && shp->oldnp!=np && !(flags&NV_ARRAY)) np->nvenv = (char*)shp->oldnp; shp->oldnp = np; if(isref) @@ -1312,7 +1312,9 @@ { cp += 2; dp->last = cp; +#if NVCACHE nvcache.ok = 0; +#endif shp->oldnp = np = nv_parentnode(shp->oldnp); if(*cp==0) return(np); @@ -2629,9 +2629,14 @@ void _nv_unset(register Namval_t *np,int } dtclose(rp->sdict); } + /* + * stkclose() does do sfclose() finally which + * its self does free() the stream slp->slptr + */ if(flags&NV_TABLE) while(stkclose(slp->slptr)==1); - sfclose(slp->slptr); + else + sfclose(slp->slptr); free((void*)np->nvalue.ip); np->nvalue.ip = 0; } --- src/lib/libast/misc/spawnvex.c +++ src/lib/libast/misc/spawnvex.c 2014-04-04 13:30:25.522235886 +0000 @@ -596,6 +596,8 @@ spawnvex_apply(Spawnvex_t* vex, int cur, } else if (i >= vex->cur) break; + if (!vex->op) + break; op = vex->op[i++].number; arg = vex->op[i++].number; if (!(op & 1)) --- src/cmd/ksh93/sh/xec.c +++ src/cmd/ksh93/sh/xec.c 2014-04-08 17:29:25.458235619 +0000 @@ -4187,7 +4187,7 @@ int sh_eval_20120720(Shell_t *shp,regist mode = sh_state(SH_INTERACTIVE); } sh_exec(shp,t,sh_isstate(shp,SH_ERREXIT)|sh_isstate(shp,SH_NOFORK)|(mode&~SH_FUNEVAL)); - if(!(mode&SH_FUNEVAL)) + if(!io_save) break; } sh_popcontext(shp,buffp);
pgpPKOniuMCGP.pgp
Description: PGP signature
_______________________________________________ ast-developers mailing list ast-developers@lists.research.att.com http://lists.research.att.com/mailman/listinfo/ast-developers