* Re: COMPLETE_IN_WORD dumps core if reserved word match
1995-08-07 11:51 ` COMPLETE_IN_WORD dumps core if reserved word match Thorsten Meinecke
@ 1995-08-07 14:06 ` Zoltan Hidvegi
1995-08-08 11:36 ` P.Stephenson
1 sibling, 0 replies; 4+ messages in thread
From: Zoltan Hidvegi @ 1995-08-07 14:06 UTC (permalink / raw)
To: zsh-workers
Thorsten Meinecke wrote:
> I wrote,
> Subject: COMPLETE_IN_WORD dumps core if built-in functions match,
>
> > Starting program: /u/home/kaefer/wrk/zsh/zsh-2.6-beta10/Src/./zsh -f
> > aglaia:~/wrk/zsh/zsh-2.6-beta10/Src> setopt autolist completeinword
> > aglaia:~/wrk/zsh/zsh-2.6-beta10/Src> rt
> > ^
> > [cursor position is here, and completion requested]
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x804ed39 in addmatch (s=0x8059424 "epeat", t=0x8059424 "epeat")
> > at zle_tricky.c:1524
> > 1524 *e = '\0';
> > (gdb)
> >
> > The obvious way around (at least for GCC) is to recompile with
> > -fwritable-strings.
>
> Digging a little further shows that only the list of 24 reserved
> words is subject to this problem. We're attempting to modify
> "string constants", which can't be done portably.
>
> The fix is to copy these words, at the expense of a-hundred-and-a-
> few bytes increased memory usage, as it was done in earlier releases.
I think it would be better to modify the code which uses the end-of-string
marks. I do not like new ztrdups. Also it requires some additional CPU time as
well (malloc can be quite slow, especially with zsh-mem, which queues signals
befor each malloc). The proper solution shouldn't be too difficult, be I have
some other things to do now.
Zoltan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: COMPLETE_IN_WORD dumps core if reserved word match
1995-08-07 11:51 ` COMPLETE_IN_WORD dumps core if reserved word match Thorsten Meinecke
1995-08-07 14:06 ` Zoltan Hidvegi
@ 1995-08-08 11:36 ` P.Stephenson
1 sibling, 0 replies; 4+ messages in thread
From: P.Stephenson @ 1995-08-08 11:36 UTC (permalink / raw)
To: Zsh hackers list
kaefer@aglaia.snafu.de wrote:
> I wrote,
> Subject: COMPLETE_IN_WORD dumps core if built-in functions match,
>
> > The obvious way around (at least for GCC) is to recompile with
> > -fwritable-strings.
>
> The fix is to copy these words, at the expense of a-hundred-and-a-
> few bytes increased memory usage, as it was done in earlier releases.
Yuk. Having to copy permanent values is not much more `politically
correct' than using -fwritable-strings. Why can't we just call
dupstring() before sticking in the null byte? I don't see why `s'
should have to point to the original string rather than a copy.
There was a line like this
t = s += (ispattern ? 0 : pl);
e += t - s;
but surely the second line is redundant? Anyway, I deleted it.
*** Src/zle_tricky.c.sav Fri Jul 28 12:47:31 1995
--- Src/zle_tricky.c Tue Aug 8 12:29:37 1995
***************
*** 1395,1401 ****
addmatch(char *s, char *t)
{
int test = 0, sl = strlen(s), pl = rpl, cc = 0, *bp, *ep;
! char sav = 0, *e = NULL, *tt, *te, *fc, **fm;
Comp cp = patcomp;
Param pm;
LinkList l = matches;
--- 1395,1401 ----
addmatch(char *s, char *t)
{
int test = 0, sl = strlen(s), pl = rpl, cc = 0, *bp, *ep;
! char *e = NULL, *tt, *te, *fc, **fm;
Comp cp = patcomp;
Param pm;
LinkList l = matches;
***************
*** 1513,1528 ****
if (!test)
return;
! t = s += (ispattern ? 0 : pl);
! e += t - s;
! s = t;
!
! if (ispattern)
! e = NULL, sav = '\0';
! else {
! if ((sav = *e)) {
! *e = '\0';
! t = dupstring(t);
}
}
--- 1513,1526 ----
if (!test)
return;
! if (ispattern) {
! t = s;
! } else {
! t = s += pl;
! if (*e) {
! sl = e - s;
! t = s = dupstring(t);
! s[sl] = '\0';
}
}
***************
*** 1561,1568 ****
fshortl = sl, fshortest = t;
else
shortl = sl, shortest = t;
- if (sav)
- *e = sav;
}
#ifdef HAVE_NIS
--- 1559,1564 ----
--
Peter Stephenson <P.Stephenson@swansea.ac.uk> Tel: +44 1792 205678 extn. 4461
WWW: http://python.swan.ac.uk/~pypeters/ Fax: +44 1792 295324
Department of Physics, University of Wales, Swansea,
Singleton Park, Swansea, SA2 8PP, U.K.
^ permalink raw reply [flat|nested] 4+ messages in thread