zsh-workers
 help / color / mirror / code / Atom feed
* Re: _complete_debug causes core dump.
@ 2000-05-12  7:02 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 2000-05-12  7:02 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On May 12,  5:07am, Tanaka Akira wrote:
> } Subject: _complete_debug causes core dump.
> }
> } _complete_debug causes core dump as follows.
> 
> It's not _complete_debug, it's _message.  If you call _message when there
> are no matches (which _complete_debug does in this case), makecomplist()
> returns 1 and docompletion() derefs a null pointer.  If you don't call
> _message (the case when _main_complete is called directly) makecomplist()
> returns 0 and most of docompletion() is bypassed by a goto.

The problem was that the branch should only be executed when there are 
matches which was ensured before that `compadd -x' change.

Bye
 Sven

Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.18
diff -u -r1.18 compcore.c
--- Src/Zle/compcore.c	2000/05/11 08:40:11	1.18
+++ Src/Zle/compcore.c	2000/05/12 07:01:13
@@ -400,7 +400,7 @@
 	if (nmatches > 1 && diffmatches) {
 	    /* There is more than one match. */
 	    ret = do_ambiguous();
-	} else if (nmatches == 1 || !diffmatches) {
+	} else if (nmatches == 1 || (nmatches > 1 && !diffmatches)) {
 	    /* Only one match. */
 	    Cmgroup m = amatches;
 

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: _complete_debug causes core dump.
  2000-05-11 20:07 Tanaka Akira
@ 2000-05-12  1:46 ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2000-05-12  1:46 UTC (permalink / raw)
  To: zsh-workers

On May 12,  5:07am, Tanaka Akira wrote:
} Subject: _complete_debug causes core dump.
}
} _complete_debug causes core dump as follows.

It's not _complete_debug, it's _message.  If you call _message when there
are no matches (which _complete_debug does in this case), makecomplist()
returns 1 and docompletion() derefs a null pointer.  If you don't call
_message (the case when _main_complete is called directly) makecomplist()
returns 0 and most of docompletion() is bypassed by a goto.

This did lead me to find a problem with _complete_debug, though.  The
change to the value of $w is just because I decided it looks nicer.

Index: Completion/Commands/_complete_debug
===================================================================
@@ -5,8 +5,9 @@
 
 (( $+_debug_count )) || integer -g _debug_count
 local tmp=${TMPPREFIX}${$}${words[1]:t}$[++_debug_count]
-local w="${(qqq)words}"
+local w="${(qq)words}"
 
+exec 3>&-	# Too bad if somebody else is using it ...
 [[ -t 2 ]] && exec 3>&2 2>| $tmp
 
 setopt xtrace
@@ -14,7 +15,7 @@
 integer ret=$?
 unsetopt xtrace
 
-[[ -t 2 ]] || {
+[[ -t 3 ]] && {
     ## Calling "print -s" during completion is presently broken.
     # _message -r "Trace output left in $tmp (up-history to view)"
     # print -sR "${VISUAL:-${EDITOR:-${PAGER:-more}}} $tmp ;: $w"



-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* _complete_debug causes core dump.
@ 2000-05-11 20:07 Tanaka Akira
  2000-05-12  1:46 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Tanaka Akira @ 2000-05-11 20:07 UTC (permalink / raw)
  To: zsh-workers

_complete_debug causes core dump as follows.

Z(4):akr@serein% Src/zsh -f  
serein% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst
serein% _tst () {}
serein% tst <C-x>?
zsh: segmentation fault (core dumped)  Src/zsh -f
Z(4):akr@serein% gdb Src/zsh core
GNU gdb 19991004
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-redhat-linux"...
Core was generated by `Src/zsh -f'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libdl.so.2...done.
Reading symbols from /lib/libnsl.so.1...done.
Reading symbols from /lib/libtermcap.so.2...done.
Reading symbols from /lib/libm.so.6...done.
Reading symbols from /lib/libc.so.6...done.
Reading symbols from /lib/ld-linux.so.2...done.
Reading symbols from /lib/libnss_files.so.2...done.
Reading symbols from /home/akr/zsh/lib/zsh/3.1.7-pre-3/zsh/zle.so...done.
Reading symbols from /home/akr/zsh/lib/zsh/3.1.7-pre-3/zsh/complete.so...done.
Reading symbols from /home/akr/zsh/lib/zsh/3.1.7-pre-3/zsh/compctl.so...done.
Reading symbols from /home/akr/zsh/lib/zsh/3.1.7-pre-3/zsh/parameter.so...done.
Reading symbols from /home/akr/zsh/lib/zsh/3.1.7-pre-3/zsh/zutil.so...done.
Reading symbols from /home/akr/zsh/lib/zsh/3.1.7-pre-3/zsh/computil.so...done.
#0  0x401f1893 in do_completion (dummy=0x401e2b48, dat=0xbffff3c0) at compcore.c:407
407                 while (!m->mcount)
(gdb) where
#0  0x401f1893 in do_completion (dummy=0x401e2b48, dat=0xbffff3c0) at compcore.c:407
#1  0x80886a9 in runhookdef (h=0x401e2b48, d=0xbffff3c0) at module.c:1615
#2  0x401d4f9b in docompletion (s=0x8101450 "", lst=0, incmd=0) at zle_tricky.c:1703
#3  0x401d20f0 in docomplete (lst=0) at zle_tricky.c:763
#4  0x401d097f in completeword (args=0x401e2ac4) at zle_tricky.c:203
#5  0x401d0857 in completecall (args=0x401e2ac4) at zle_tricky.c:180
#6  0x401c5d01 in execzlefunc (func=0x80f99e8, args=0x401e2ac4) at zle_main.c:645
#7  0x401c591c in zleread (lp=0x80e0a90 "%m%# ", rp=0x0, flags=3) at zle_main.c:564
#8  0x80762b5 in inputline () at input.c:265
#9  0x80761a6 in ingetc () at input.c:210
#10 0x806f088 in ihgetc () at hist.c:242
#11 0x807b4e8 in gettok () at lex.c:621
#12 0x807acd5 in yylex () at lex.c:337
#13 0x8090ee3 in parse_event () at parse.c:421
#14 0x80737c1 in loop (toplevel=1, justonce=0) at init.c:121
#15 0x8051752 in main (argc=2, argv=0xbffff784) at ./main.c:86
(gdb) 
-- 
Tanaka Akira


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-05-12  7:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-12  7:02 _complete_debug causes core dump Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-05-11 20:07 Tanaka Akira
2000-05-12  1:46 ` Bart Schaefer

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).