VirtualBox

Changeset 3458 in kBuild


Ignore:
Timestamp:
Sep 14, 2020 9:46:32 PM (5 years ago)
Author:
bird
Message:

kash: Use reference counting of parser output in threaded-mode.

Location:
trunk/src/kash
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/Makefile.kmk

    r3457 r3458  
    3636kash_NAME = kmk_ash
    3737kash_ASTOOL = YASM
    38 kash_DEFS = lint SHELL SMALL #KASH_SEPARATE_PARSER_ALLOCATOR
     38kash_DEFS = lint SHELL SMALL KASH_SEPARATE_PARSER_ALLOCATOR
    3939if "$(KBUILD_TARGET)" != "win" || defined(KASH_WIN_FORKED_MODE)
    4040kash_DEFS += SH_FORKED_MODE
     41else
     42kash_DEFS += KASH_SEPARATE_PARSER_ALLOCATOR
    4143endif
    4244kash_DEFS.debug = DEBUG=2
  • trunk/src/kash/eval.c

    r3455 r3458  
    11121112           (flags != EV_BACKCMD as EV_EXIT is ORed in). */
    11131113
    1114         /* If cmdentry references an internal function, we must duplicates it's nodes. */
     1114        /* If cmdentry references an internal function, we must duplicates (reference) it's nodes. */
    11151115        if (args->cmdentry.cmdtype == CMDFUNCTION)
    11161116                args->cmdentry.u.func = copyparsetree(pshchild, args->cmdentry.u.func); /** @todo isn't this duplicated already? */
  • trunk/src/kash/generated/nodes.c

    r3449 r3458  
    5151#include "shinstance.h"
    5252
     53#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    5354
    5455size_t  funcblocksize;          /* size of structures in function */
     
    9394STATIC char *nodesavestr(char *);
    9495
     96#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    9597
    9698
     
    104106        union node *n;
    105107{
     108#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     109        if (n != NULL) {
     110                unsigned refs = pstackretain(n->pblock);
     111                TRACE2((psh, "copyfunc: %p - %u refs\n", n->pblock, refs)); K_NOREF(refs);
     112        }
     113        return n;
     114#else
    106115        if (n == NULL)
    107116                return NULL;
     
    112121        funcstring = (char *) funcblock + funcblocksize;
    113122        return copynode(n);
    114 }
    115 
    116 
     123#endif
     124}
     125
     126#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    117127
    118128STATIC void
     
    274284      case NAPPEND:
    275285            new->nfile.fname = copynode(n->nfile.fname);
     286            new->nfile.next = copynode(n->nfile.next);
    276287            new->nfile.fd = n->nfile.fd;
    277             new->nfile.next = copynode(n->nfile.next);
    278288            break;
    279289      case NTOFD:
     
    281291            new->ndup.vname = copynode(n->ndup.vname);
    282292            new->ndup.dupfd = n->ndup.dupfd;
     293            new->ndup.next = copynode(n->ndup.next);
    283294            new->ndup.fd = n->ndup.fd;
    284             new->ndup.next = copynode(n->ndup.next);
    285295            break;
    286296      case NHERE:
    287297      case NXHERE:
    288298            new->nhere.doc = copynode(n->nhere.doc);
     299            new->nhere.next = copynode(n->nhere.next);
    289300            new->nhere.fd = n->nhere.fd;
    290             new->nhere.next = copynode(n->nhere.next);
    291301            break;
    292302      case NNOT:
     
    335345}
    336346
     347#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    337348
    338349
     
    343354void
    344355freefunc(psh, n)
    345     shinstance *psh;
     356        shinstance *psh;
    346357        union node *n;
    347358{
     359#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     360        if (n)
     361                pstackrelease(psh, n->pblock, "freefunc");
     362#else
    348363        if (n)
    349364                ckfree(psh, n);
    350 }
     365#endif
     366}
  • trunk/src/kash/generated/nodes.h

    r3449 r3458  
    3333
    3434struct nbinary {
    35       int type;
    36       union node *ch1;
    37       union node *ch2;
     35#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     36        struct pstack_block *pblock;
     37#endif
     38        int type;
     39        union node *ch1;
     40        union node *ch2;
    3841};
    3942
    4043
    4144struct ncmd {
    42       int type;
    43       int backgnd;
    44       union node *args;
    45       union node *redirect;
     45#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     46        struct pstack_block *pblock;
     47#endif
     48        int type;
     49        int backgnd;
     50        union node *args;
     51        union node *redirect;
    4652};
    4753
    4854
    4955struct npipe {
    50       int type;
    51       int backgnd;
    52       struct nodelist *cmdlist;
     56#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     57        struct pstack_block *pblock;
     58#endif
     59        int type;
     60        int backgnd;
     61        struct nodelist *cmdlist;
    5362};
    5463
    5564
    5665struct nredir {
    57       int type;
    58       union node *n;
    59       union node *redirect;
     66#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     67        struct pstack_block *pblock;
     68#endif
     69        int type;
     70        union node *n;
     71        union node *redirect;
    6072};
    6173
    6274
    6375struct nif {
    64       int type;
    65       union node *test;
    66       union node *ifpart;
    67       union node *elsepart;
     76#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     77        struct pstack_block *pblock;
     78#endif
     79        int type;
     80        union node *test;
     81        union node *ifpart;
     82        union node *elsepart;
    6883};
    6984
    7085
    7186struct nfor {
    72       int type;
    73       union node *args;
    74       union node *body;
    75       char *var;
     87#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     88        struct pstack_block *pblock;
     89#endif
     90        int type;
     91        union node *args;
     92        union node *body;
     93        char *var;
    7694};
    7795
    7896
    7997struct ncase {
    80       int type;
    81       union node *expr;
    82       union node *cases;
     98#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     99        struct pstack_block *pblock;
     100#endif
     101        int type;
     102        union node *expr;
     103        union node *cases;
    83104};
    84105
    85106
    86107struct nclist {
    87       int type;
    88       union node *next;
    89       union node *pattern;
    90       union node *body;
     108#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     109        struct pstack_block *pblock;
     110#endif
     111        int type;
     112        union node *next;
     113        union node *pattern;
     114        union node *body;
    91115};
    92116
    93117
    94118struct narg {
    95       int type;
    96       union node *next;
    97       char *text;
    98       struct nodelist *backquote;
     119#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     120        struct pstack_block *pblock;
     121#endif
     122        int type;
     123        union node *next;
     124        char *text;
     125        struct nodelist *backquote;
    99126};
    100127
    101128
    102129struct nfile {
    103       int type;
    104       int fd;
    105       union node *next;
    106       union node *fname;
     130#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     131        struct pstack_block *pblock;
     132#endif
     133        int type;
     134        int fd;
     135        union node *next;
     136        union node *fname;
    107137};
    108138
    109139
    110140struct ndup {
    111       int type;
    112       int fd;
    113       union node *next;
    114       int dupfd;
    115       union node *vname;
     141#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     142        struct pstack_block *pblock;
     143#endif
     144        int type;
     145        int fd;
     146        union node *next;
     147        int dupfd;
     148        union node *vname;
    116149};
    117150
    118151
    119152struct nhere {
    120       int type;
    121       int fd;
    122       union node *next;
    123       union node *doc;
     153#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     154        struct pstack_block *pblock;
     155#endif
     156        int type;
     157        int fd;
     158        union node *next;
     159        union node *doc;
    124160};
    125161
    126162
    127163struct nnot {
    128       int type;
    129       union node *com;
     164#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     165        struct pstack_block *pblock;
     166#endif
     167        int type;
     168        union node *com;
    130169};
    131170
    132171
    133172union node {
    134       int type;
    135       struct nbinary nbinary;
    136       struct ncmd ncmd;
    137       struct npipe npipe;
    138       struct nredir nredir;
    139       struct nif nif;
    140       struct nfor nfor;
    141       struct ncase ncase;
    142       struct nclist nclist;
    143       struct narg narg;
    144       struct nfile nfile;
    145       struct ndup ndup;
    146       struct nhere nhere;
    147       struct nnot nnot;
     173#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     174# ifdef __GNUC__
     175        __extension__
     176# endif
     177        struct {
     178                struct pstack_block *pblock;
     179                int type;
     180        };
     181#else
     182        int type;
     183#endif
     184        struct nbinary nbinary;
     185        struct ncmd ncmd;
     186        struct npipe npipe;
     187        struct nredir nredir;
     188        struct nif nif;
     189        struct nfor nfor;
     190        struct ncase ncase;
     191        struct nclist nclist;
     192        struct narg narg;
     193        struct nfile nfile;
     194        struct ndup ndup;
     195        struct nhere nhere;
     196        struct nnot nnot;
    148197};
    149198
  • trunk/src/kash/memalloc.c

    r3457 r3458  
    207207
    208208#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
    209         assert(mark->pstacksize <= psh->pstacksize);
    210         while (mark->pstacksize < psh->pstacksize) {
    211                 unsigned idx = --psh->pstacksize;
    212                 pstack_block *psk = psh->pstack[idx];
    213                 psh->pstack[idx] = NULL;
    214                 if (psh->curpstack == psk)
    215                     psh->curpstack = idx > 0 ? psh->pstack[idx - 1] : NULL;
    216                 pstackrelease(psh, psk);
    217         }
    218 
    219 # ifndef NDEBUG
    220         if (psh->curpstack) {
    221                 unsigned i;
    222                 for (i = 0; i < psh->pstacksize; i++)
    223                         if (psh->curpstack == psh->pstack[i])
    224                                 break;
    225                 assert(i < psh->pstacksize);
    226         }
    227 # endif
     209        pstackpop(psh, mark->pstacksize);
    228210#endif
    229211        INTON;
     
    382364#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
    383365
    384 unsigned pstackretain(pstack_block *pst)
    385 {
    386         unsigned refs = sh_atomic_inc(&pst->refs);
    387         assert(refs > 1);
    388         assert(refs < 256 /* bogus, but useful */);
    389         return refs;
    390 }
    391 
    392 unsigned pstackrelease(shinstance *psh, pstack_block *pst)
     366unsigned pstackrelease(shinstance *psh, pstack_block *pst, const char *caller)
    393367{
    394368        unsigned refs;
    395369        if (pst) {
    396370                refs = sh_atomic_dec(&pst->refs);
     371                TRACE2((NULL, "pstackrelease: %p - %u refs (%s)\n", pst, refs, caller)); K_NOREF(caller);
    397372                if (refs == 0) {
    398373                        shinstance * const psh = shthread_get_shell();
     
    407382                        pst->nextbyte = NULL;
    408383                        pst->top = NULL;
     384                        /** @todo push into an alloc cache rather than freeing it */
    409385                        sh_free(psh, pst);
    410386                }
     
    414390}
    415391
    416 pstack_block *pstackpush(shinstance *psh)
     392void pstackpop(shinstance *psh, unsigned target)
     393{
     394        assert(target <= psh->pstacksize);
     395        while (target < psh->pstacksize) {
     396                unsigned idx = --psh->pstacksize;
     397                pstack_block *psk = psh->pstack[idx];
     398                psh->pstack[idx] = NULL;
     399                if (psh->curpstack == psk)
     400                    psh->curpstack = idx > 0 ? psh->pstack[idx - 1] : NULL;
     401                pstackrelease(psh, psk, "popstackmark");
     402        }
     403
     404# ifndef NDEBUG
     405        if (psh->curpstack) {
     406                unsigned i;
     407                for (i = 0; i < psh->pstacksize; i++)
     408                        if (psh->curpstack == psh->pstack[i])
     409                                break;
     410                assert(i < psh->pstacksize);
     411        }
     412# endif
     413}
     414
     415
     416unsigned pstackretain(pstack_block *pst)
     417{
     418        unsigned refs = sh_atomic_inc(&pst->refs);
     419        assert(refs > 1);
     420        assert(refs < 256 /* bogus, but useful */);
     421        return refs;
     422}
     423
     424K_INLINE void pstackpush(shinstance *psh, pstack_block *pst)
     425{
     426        unsigned i = psh->pstacksize;
     427        if (i + 1 < psh->pstackalloced) {
     428                /* likely, except for the first time */
     429        } else {
     430                psh->pstack = (pstack_block **)ckrealloc(psh, psh->pstack, sizeof(psh->pstack[0]) * (i + 32));
     431                memset(&psh->pstack[i], 0, sizeof(psh->pstack[0]) * 32);
     432        }
     433        psh->pstack[i] = pst;
     434        psh->pstacksize = i + 1;
     435}
     436
     437/* Does not make it current! */
     438unsigned pstackretainpush(shinstance *psh, pstack_block *pst)
     439{
     440        unsigned refs = pstackretain(pst);
     441        pstackpush(psh, pst);
     442        TRACE2((psh, "pstackretainpush: %p - entry %u - %u refs\n", pst, psh->pstacksize - 1, refs));
     443        return refs;
     444}
     445
     446pstack_block *pstackallocpush(shinstance *psh)
    417447{
    418448        size_t const blocksize = offsetof(pstack_block, first.space) + MINSIZE;
    419449        pstack_block *pst;
    420         unsigned i;
    421450
    422451        INTOFF;
     
    443472
    444473        /*
    445          * Push it onto the stack.
     474         * Push it onto the stack and make it current.
    446475         */
    447         i = psh->pstacksize;
    448         if (i + 1 < psh->pstackalloced) {
    449                 /* likely, except for the first time */
    450         } else {
    451                 psh->pstack = (pstack_block **)ckrealloc(psh, psh->pstack, sizeof(psh->pstack[0]) * (i + 32));
    452                 memset(&psh->pstack[i], 0, sizeof(psh->pstack[0]) * 32);
    453         }
    454         psh->pstack[i] = pst;
    455         psh->pstacksize = i + 1;
     476        pstackpush(psh, pst);
    456477        psh->curpstack = pst;
    457478
    458479        INTON;
     480        TRACE2((psh, "pstackallocpush: %p - entry %u\n", pst, psh->pstacksize - 1));
    459481        return pst;
    460482}
     
    565587{
    566588#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
    567         pstack_block *pst = psh->curpstack;
     589        pstack_block * const pst = psh->curpstack;
     590        union node * const ret = (union node *)pstallocint(psh, pst, nbytes);
    568591        pst->nodesalloced++;
    569         return (union node *)pstallocint(psh, pst, nbytes);
     592        ret->pblock = pst;
     593        return ret;
    570594#else
    571595        return (union node *)pstalloc(psh, nbytes);
  • trunk/src/kash/memalloc.h

    r3457 r3458  
    9090struct pstack_block;
    9191unsigned pstackretain(struct pstack_block *);
    92 unsigned pstackrelease(struct shinstance *, struct pstack_block *);
    93 struct pstack_block *pstackpush(struct shinstance *);
     92void pstackpop(struct shinstance *, unsigned);
     93unsigned pstackrelease(struct shinstance *, struct pstack_block *, const char *);
     94unsigned pstackretainpush(struct shinstance *, struct pstack_block *);
     95struct pstack_block *pstackallocpush(struct shinstance *);
    9496#endif
    9597void *pstalloc(struct shinstance *, size_t);
  • trunk/src/kash/mknodes.sh

    r3449 r3458  
    7373echo
    7474
     75## @todo inconsistent indentation here.
    7576IFS=' '
    7677for struct in $struct_list; do
     
    7879        echo
    7980        echo "struct $struct {"
     81        echo "#ifdef KASH_SEPARATE_PARSER_ALLOCATOR"
     82        echo "  struct pstack_block *pblock;"
     83        echo "#endif"
    8084        field=0
    8185        while
     
    9498                * ) name=; shift 2; type="$*";;
    9599                esac
    96                 echo "      $type$name;"
     100                echo "  $type$name;"
    97101        done
    98102        echo "};"
     
    102106echo
    103107echo "union node {"
    104 echo "      int type;"
     108echo "#ifdef KASH_SEPARATE_PARSER_ALLOCATOR"
     109echo "# ifdef __GNUC__"
     110echo "  __extension__"
     111echo "# endif"
     112echo "  struct {"
     113echo "          struct pstack_block *pblock;"
     114echo "          int type;"
     115echo "  };"
     116echo "#else"
     117echo "  int type;"
     118echo "#endif"
    105119for struct in $struct_list; do
    106         echo "      struct $struct $struct;"
     120        echo "  struct $struct $struct;"
    107121done
    108122echo "};"
  • trunk/src/kash/nodes.c.pat

    r2391 r3458  
    4747#include "shinstance.h"
    4848
     49#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    4950
    5051size_t  funcblocksize;          /* size of structures in function */
     
    6263STATIC char *nodesavestr(char *);
    6364
     65#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    6466
    6567
     
    7375        union node *n;
    7476{
     77#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     78        if (n != NULL) {
     79                unsigned refs = pstackretain(n->pblock);
     80                TRACE2((psh, "copyfunc: %p - %u refs\n", n->pblock, refs)); K_NOREF(refs);
     81        }
     82        return n;
     83#else
    7584        if (n == NULL)
    7685                return NULL;
     
    8190        funcstring = (char *) funcblock + funcblocksize;
    8291        return copynode(n);
     92#endif
    8393}
    8494
    85 
     95#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
    8696
    8797STATIC void
     
    154164}
    155165
     166#endif /* !KASH_SEPARATE_PARSER_ALLOCATOR */
    156167
    157168
     
    165176        union node *n;
    166177{
     178#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
     179        if (n)
     180                pstackrelease(psh, n->pblock, "freefunc");
     181#else
    167182        if (n)
    168183                ckfree(psh, n);
     184#endif
    169185}
  • trunk/src/kash/parser.c

    r3457 r3458  
    136136        TRACE2((psh, "parsecmd(%d)\n", interact));
    137137#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
    138         pstackpush(psh);
     138        pstackallocpush(psh);
    139139#endif
    140140        psh->tokpushback = 0;
     
    17881788}
    17891789
     1790#ifndef KASH_SEPARATE_PARSER_ALLOCATOR
     1791
    17901792static union node *copyparsetreeint(shinstance *psh, union node *src);
    17911793
     
    19471949}
    19481950
     1951#endif
     1952
    19491953union node *copyparsetree(shinstance *psh, union node *src)
    19501954{
    19511955#ifdef KASH_SEPARATE_PARSER_ALLOCATOR
    1952         pstackpush(psh);
     1956        K_NOREF(psh);
     1957        pstackretainpush(psh, src->pblock);
     1958        return src;
     1959#else
     1960        return copyparsetreeint(psh, src);
    19531961#endif
    1954         return copyparsetreeint(psh, src);
    1955 }
    1956 
     1962}
     1963
  • trunk/src/kash/shfile.c

    r3454 r3458  
    921921 * Safe to call more than once.
    922922 */
    923 void shfile_uninit(shfdtab *pfdtab)
     923void shfile_uninit(shfdtab *pfdtab, int tracefd)
    924924{
    925925    if (!pfdtab)
     
    930930        unsigned left = pfdtab->size;
    931931        struct shfile *pfd = pfdtab->tab;
     932        unsigned tracefdfound = 0;
    932933        while (left-- > 0)
    933934        {
    934935            if (pfd->fd != -1)
    935936            {
     937                if (pfd->fd != tracefd)
     938                {
    936939#if K_OS == K_OS_WINDOWS
    937                 BOOL rc = CloseHandle((HANDLE)pfd->native);
    938                 assert(rc == TRUE); K_NOREF(rc);
    939 #else
    940                 int rc = close((int)pfd->native);
    941                 assert(rc == 0); K_NOREF(rc);
    942 #endif
    943                 pfd->fd     = -1;
    944                 pfd->native = -1;
     940                    BOOL rc = CloseHandle((HANDLE)pfd->native);
     941                    assert(rc == TRUE); K_NOREF(rc);
     942#else
     943                    int rc = close((int)pfd->native);
     944                    assert(rc == 0); K_NOREF(rc);
     945#endif
     946                    pfd->fd     = -1;
     947                    pfd->native = -1;
     948                }
     949                else
     950                    tracefdfound++; /* there is only the one */
    945951            }
    946952            pfd++;
    947953        }
     954
     955        if (!tracefdfound)
     956        { /* likely */ }
     957        else
     958            return;
    948959
    949960        sh_free(NULL, pfdtab->tab);
  • trunk/src/kash/shfile.h

    r3447 r3458  
    132132
    133133int shfile_init(shfdtab *, shfdtab *);
    134 void shfile_uninit(shfdtab *);
     134void shfile_uninit(shfdtab *, int);
    135135void shfile_fork_win(shfdtab *pfdtab, int set, intptr_t *hndls);
    136136typedef struct shfdexecwin
  • trunk/src/kash/shinstance.c

    r3451 r3458  
    4444#include "error.h"
    4545#include "memalloc.h"
     46#include "nodes.h"
    4647#include "redir.h"
    4748#include "shell.h"
     
    274275    unsigned left, i;
    275276
     277    INTOFF;
     278
    276279    sh_int_unlink(psh);
    277     shfile_uninit(&psh->fdtab);
     280    shfile_uninit(&psh->fdtab, psh->tracefd);
    278281    sh_free_string_vector(psh, &psh->shenviron);
    279282
     
    328331    struct arglist      exparg;         /**< holds expanded arg list */
    329332    char               *expdir;         /**< Used by expandmeta. */
    330 
    331     /* exec.h */
    332     const char         *pathopt;        /**< set by padvance */
    333 
    334     /* exec.c */
    335     struct tblentry    *cmdtable[CMDTABLESIZE];
    336     int                 builtinloc/* = -1*/;    /**< index in path of %builtin, or -1 */
    337 
     333#endif
     334
     335    /* exec.h/exec.c */
     336    psh->pathopt = NULL;
     337    for (i = 0; i < CMDTABLESIZE; i++)
     338    {
     339        struct tblentry *cur = psh->cmdtable[i];
     340        if (cur)
     341        {
     342            do
     343            {
     344                struct tblentry *next = cur->next;
     345                if (cur->cmdtype == CMDFUNCTION)
     346                {
     347                    freefunc(psh, cur->param.func);
     348                    cur->param.func = NULL;
     349                }
     350                sh_free(psh, cur);
     351                cur = next;
     352            } while (cur);
     353            psh->cmdtable[i] = NULL;
     354        }
     355    }
     356
     357#if 0
    338358    /* input.h */
    339359    int                 plinno/* = 1 */;/**< input line number */
     
    382402    int                 sstrnleft;
    383403    int                 herefd/* = -1 */;
    384 
    385     /* memalloc.c */
    386     struct stack_block  stackbase;
    387     struct stack_block *stackp/* = &stackbase*/;
    388     struct stackmark   *markp;
    389404
    390405    /* myhistedit.h */
     
    491506#endif
    492507
    493 /** @todo finish this...   */
     508    /*
     509     * memalloc.c: Make sure we've gotten rid of all the stack memory.
     510     */
     511    if (psh->stackp != &psh->stackbase && psh->stackp)
     512    {
     513        struct stack_block *stackp = psh->stackp;
     514        do
     515        {
     516            psh->stackp = stackp->prev;
     517            sh_free(psh, stackp);
     518        } while ((stackp = psh->stackp) != &psh->stackbase && stackp);
     519    }
     520#ifdef KASH_SEPARATE_PARSER_ALLOCATOR //bp msvcr100!_wassert
     521    if (psh->pstack)
     522    {
     523        if (psh->pstacksize > 0)
     524            pstackpop(psh, 0);
     525        sh_free(psh, psh->pstack);
     526        psh->pstack = NULL;
     527    }
     528#endif
     529    psh->markp = NULL;
     530
     531
     532    /*
     533     * Finally get rid of tracefd and then free the shell:
     534     */
     535    shfile_uninit(&psh->fdtab, -1);
     536
    494537    memset(psh, 0, sizeof(*psh));
    495538    sh_free(NULL, psh);
     
    673716{
    674717    /*
     718     * Make sure we can use TRACE/TRACE2 for logging here.
     719     */
     720#ifdef DEBUG
     721    /* show.c */
     722    psh->tracefd = inherit->tracefd;
     723    /* options.c */
     724    debug(psh) = debug(inherit);
     725#endif
     726
     727    /*
    675728     * Do the rest of the inheriting.
    676729     */
     
    743796    /* redir.c */
    744797    subshellinitredir(psh, inherit);
    745 
    746     /* show.c */
    747     psh->tracefd = inherit->tracefd;
    748798
    749799    /* trap.h / trap.c */ /** @todo we don't carry pendingsigs to the subshell, right? */
     
    16631713    {
    16641714        TRACE2((psh, "sh__exit: %u shells around, must wait...\n", g_num_shells));
    1665         shfile_uninit(&psh->fdtab);
     1715        shfile_uninit(&psh->fdtab, psh->tracefd);
    16661716        sh_int_unlink(psh);
    16671717        /** @todo    */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette