Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: crashes when setting COLUMNS=0 or 1

On Jun 26,  1:38pm, Geoff Wing wrote:
} Old versions of Zsh never let COLUMNS be set to 0 or negative numbers.

Not precisely true.  Here's zsh 2.4:

torch<501> COLUMNS=-1
torch<502> print $COLUMNS
*** glibc detected *** malloc(): memory corruption (fast): 0x0809d838 ***
zsh: abort (core dumped)  src/zsh

} It would retain its old value if you tried since it just doesn't make
} sense.  This behaviour should be recovered.

In 2.4, putprompt() would force columns = 80 when columns == 0, but there
isn't any test I can find for columns < 0.

In recent version adjustcolumns() has this:

    if (signalled || zterm_columns <= 0)
        zterm_columns = shttyinfo.winsize.ws_col;
        shttyinfo.winsize.ws_col = zterm_columns;
#endif /* TIOCGWINSZ */
    if (zterm_columns <= 0) {
        DPUTS(signalled, "BUG: Impossible TIOCGWINSZ cols");
        zterm_columns = tccolumns > 0 ? tccolumns : 80;

This is called from adjustwinsize(), and from various bits of params.c:

IPDEF5("COLUMNS", &zterm_columns, zlevar_gsu)

static const struct gsu_integer zlevar_gsu =
{ intvargetfn, zlevarsetfn, stdunsetfn };

zlevarsetfn(Param pm, zlong x)
    zlong *p = pm->u.valptr;

    *p = x;
    if (p == &zterm_lines || p == &zterm_columns)
        adjustwinsize(2 + (p == &zterm_columns));

But for some reason zlvarsetfn is never called when assigning COLUMNS,
so adjustwinsize() never happens.

Tracing through, COLUMNS=0 is handled by addvars() via execsimple(),
which does call v->pm->gsu.i->setfn at params.c:2343 ... but that's
the generic intvarsetfn, zlevarsetfn has been lost somewhere along
the way.

This may indicate there's a more generalized problem with the handling
of parameters for which IPDEF* have assigned a custom gsu.

Messages sorted by: Reverse Date, Date, Thread, Author