* Segfault in completion code
@ 2003-07-27 1:42 Haakon Riiser
2003-07-31 20:33 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Haakon Riiser @ 2003-07-27 1:42 UTC (permalink / raw)
To: zsh-workers
Steps to reproduce:
% unset IFS
% <try to perform any type of completion>
zsh: segmentation fault zsh
Verified on several systems and versions:
zsh 4.1.1 (i686-pc-linux-gnu)
zsh 4.0.2 (i686-pc-linux-gnu)
zsh 4.0.2 (sparc-sun-solaris2.6)
I know that the zsh manual doesn't make any promises as to what
happens when IFS is unset, but I assumed it would be okay since
bash explicitly allows it. Regardless, segfaulting over it seems
a bit harsh, so I would guess it's a bug. :-)
--
Haakon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Segfault in completion code
2003-07-27 1:42 Segfault in completion code Haakon Riiser
@ 2003-07-31 20:33 ` Peter Stephenson
2003-07-31 21:33 ` Haakon Riiser
0 siblings, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2003-07-31 20:33 UTC (permalink / raw)
To: zsh-workers
Haakon Riiser wrote:
> Steps to reproduce:
>
> % unset IFS
> % <try to perform any type of completion>
> zsh: segmentation fault zsh
This fixes a problem, is it the one you came across?
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.51
diff -u -r1.51 utils.c
--- Src/utils.c 13 May 2003 12:50:32 -0000 1.51
+++ Src/utils.c 31 Jul 2003 20:25:36 -0000
@@ -2054,10 +2054,12 @@
if (!*s)
return heap ? "" : ztrdup("");
if (!sep) {
- sep = sepbuf;
- sepbuf[0] = *ifs;
- sepbuf[1] = *ifs == Meta ? ifs[1] ^ 32 : '\0';
- sepbuf[2] = '\0';
+ p = sep = sepbuf;
+ if (ifs) {
+ *p++ = *ifs;
+ *p++ = *ifs == Meta ? ifs[1] ^ 32 : '\0';
+ }
+ *p = '\0';
}
sl = strlen(sep);
for (t = s, l = 1 - sl; *t; l += strlen(*t) + sl, t++);
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Segfault in completion code
2003-07-31 20:33 ` Peter Stephenson
@ 2003-07-31 21:33 ` Haakon Riiser
2003-08-01 10:58 ` Peter Stephenson
0 siblings, 1 reply; 4+ messages in thread
From: Haakon Riiser @ 2003-07-31 21:33 UTC (permalink / raw)
To: zsh-workers
[Peter Stephenson]
> This fixes a problem, is it the one you came across?
[patch deleted]
I applied your patch to zsh 4.1.1, and now it doesn't segfault
anymore. Thanks! :-)
But, there are still problems when SH_WORD_SPLIT is set. Here's an
example that should not depend on my local zsh configuration
(assuming that "zsh -f" only tries to load /etc/zshenv, which
does not exist on my system):
% /path/to/patched/zsh -f
% unset IFS
% setopt SH_WORD_SPLIT
% autoload -U compinit
% compinit
% <press completion key>
(eval):setopt:1: no such option: globbareglobqualnullglobrcexpand\
paramextendedglobunsetNO_markdirsNO_globsubstNO_shwordsplitNO_shglob\
NO_kshglobNO_ksharraysNO_cshnullglobNO_allexportNO_aliasesNO_errexit\
NO_octalzeroes
(I reformatted the last line for readability.)
--
Haakon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Segfault in completion code
2003-07-31 21:33 ` Haakon Riiser
@ 2003-08-01 10:58 ` Peter Stephenson
0 siblings, 0 replies; 4+ messages in thread
From: Peter Stephenson @ 2003-08-01 10:58 UTC (permalink / raw)
To: zsh-workers
Haakon Riiser wrote:
> But, there are still problems when SH_WORD_SPLIT is set. Here's an
> example that should not depend on my local zsh configuration
> (assuming that "zsh -f" only tries to load /etc/zshenv, which
> does not exist on my system):
>
> % /path/to/patched/zsh -f
> % unset IFS
> % setopt SH_WORD_SPLIT
> % autoload -U compinit
> % compinit
> % <press completion key>
> (eval):setopt:1: no such option: globbareglobqualnullglobrcexpand\
> paramextendedglobunsetNO_markdirsNO_globsubstNO_shwordsplitNO_shglob\
> NO_kshglobNO_ksharraysNO_cshnullglobNO_allexportNO_aliasesNO_errexit\
> NO_octalzeroes
The combined effect of shwordsplit and unsetting IFS causes the values
in the list of options to be joined together with no spaces between.
It looks harmless to put it back (IFS might be anything).
However, my patch last night was wrong --- I've checked SUS/Posix 2003
and it says:
IFS (Input Field Separators.) A string treated as a list of characters
that is used for field splitting and to split lines into fields with
the read command. If IFS is not set, the shell shall behave as if
the value of IFS is <space>, <tab>, and <newline>; see Field
Splitting . Implementations may ignore the value of IFS in the
environment at the time the shell is invoked, treating IFS as if it
were not set.
so we should use space to join words. I don't know why it doesn't allow
you to use no separator, but it doesn't. This is already handled
correctly in other parts of the shell --- we use a default IFS. That
fixes the immediate problem above, but as I said IFS might be something
else, so I've still supplied the other hunk. The following patch
applies on top of last night's fix (now committed).
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.52
diff -u -r1.52 utils.c
--- Src/utils.c 1 Aug 2003 09:55:41 -0000 1.52
+++ Src/utils.c 1 Aug 2003 10:56:54 -0000
@@ -2058,6 +2058,8 @@
if (ifs) {
*p++ = *ifs;
*p++ = *ifs == Meta ? ifs[1] ^ 32 : '\0';
+ } else {
+ *p++ = ' ';
}
*p = '\0';
}
Index: Completion/Base/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_main_complete,v
retrieving revision 1.7
diff -u -r1.7 _main_complete
--- Completion/Base/Core/_main_complete 26 Feb 2003 16:36:06 -0000 1.7
+++ Completion/Base/Core/_main_complete 1 Aug 2003 10:45:31 -0000
@@ -3,6 +3,8 @@
# The main loop of the completion code. This is what is called when
# completion is attempted from the command line.
+# In case non-standard separators are in use.
+local IFS=$' \t\n\0'
# If you want to complete only set or unset options for the unsetopt
# and setopt builtin, un-comment these lines:
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 692070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-08-01 15:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-27 1:42 Segfault in completion code Haakon Riiser
2003-07-31 20:33 ` Peter Stephenson
2003-07-31 21:33 ` Haakon Riiser
2003-08-01 10:58 ` Peter Stephenson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).