zsh-workers
 help / color / mirror / code / Atom feed
* completing in the middle of the command line causes coredump
@ 2008-04-21  9:56 Jun T.
  2008-04-21 10:11 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Jun T. @ 2008-04-21  9:56 UTC (permalink / raw)
  To: zsh-workers

zsh (the latest CVS) coredumps while completing in the middle of the command line.

zsh -f
setopt combiningchars
ls a<TAB>       # this is OK
ls a<^B><TAB>   # coredump

Here, <^B> is to move the cursor back to 'a'.
zsh coredumps if you hit <TAB> when the cursor is on 'a'.

coredump is at line 58 of zle_move.c:

58          if (!iswpunct(zleline[loccs]) || wcwidth(zleline[loccs]) != 0)

zleline is NULL because the command line is metafied.

If there is no files staring with 'a' in the current directory, the gdb back
trace is

(gdb) bt
#0  0x00215584 in alignmultiwordleft (pos=0x236c40, setpos=0) at zle_move.c:58
#1  0x00215725 in alignmultiwordright (pos=0x236c40, setpos=1) at zle_move.c:98
#2  0x0022a96f in foredel (ct=4, flags=4) at zle_utils.c:667
#3  0x000ddc7d in do_completion (dummy=0x2363d4, dat=0xbffff584) at compcore.c:352
#4  0x0004e95a in runhookdef (h=0x2363d4, d=0xbffff584) at module.c:996
#5  0x00227142 in docompletion (s=0x310de0 "a", lst=0, incmd=0) at zle_tricky.c:2135
#6  0x00222d22 in docomplete (lst=0) at zle_tricky.c:859
#7  0x002215f5 in expandorcomplete (args=0x236320) at zle_tricky.c:315
#8  0x0020fe32 in execzlefunc (func=0x2341f0, args=0x236320, set_bindk=0) at zle_main.c:1298
#9  0x0020f20d in zlecore () at zle_main.c:1043
#10 0x0020f9e4 in zleread (lp=0xa1f60, rp=0x0, flags=3, context=0) at zle_main.c:1205
#11 0x000391d4 in inputline () at input.c:278
#12 0x00038fe6 in ingetc () at input.c:214
#13 0x0002d74d in ihgetc () at hist.c:240
#14 0x00041fa2 in gettok () at lex.c:663
#15 0x00041484 in yylex () at lex.c:350
#16 0x00060739 in parse_event () at parse.c:451
#17 0x00035400 in loop (toplevel=1, justonce=0) at init.c:129
#18 0x00038b64 in zsh_main (argc=2, argv=0xbffffb3c) at init.c:1352
#19 0x00001b6a in main (argc=2, argv=0xbffffb3c) at main.c:93
(gdb) 

If there are files staring with 'a', #0 to #4 is replaced by the following 5 lines:

(gdb) bt
#0  0x00215584 in alignmultiwordleft (pos=0x236c40, setpos=0) at zle_move.c:58
#1  0x00215725 in alignmultiwordright (pos=0x236c40, setpos=1) at zle_move.c:98
#2  0x0022a96f in foredel (ct=3, flags=4) at zle_utils.c:667
#3  0x000f171a in do_single (m=0x314410) at compresult.c:981
#4  0x000ddff3 in do_completion (dummy=0x2363d4, dat=0xbffff584) at compcore.c:413
#5  0x0004e95a in runhookdef (h=0x2363d4, d=0xbffff584) at module.c:996


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

* Re: completing in the middle of the command line causes coredump
  2008-04-21  9:56 completing in the middle of the command line causes coredump Jun T.
@ 2008-04-21 10:11 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2008-04-21 10:11 UTC (permalink / raw)
  To: zsh-workers

"Jun T." wrote:
> zsh (the latest CVS) coredumps while completing in the middle of the command 
> line.
> 
> zleline is NULL because the command line is metafied.

Yes, I wasn't careful enough with the tests.  We need to delay the
checks until we get back to an unmetafied command line.

I've been dreaming about a proper interface between completion and the
rest of the shell, most particularly the main line editor so we can trap
inserts, deletions and replacements properly.

Index: Src/Zle/zle_utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_utils.c,v
retrieving revision 1.50
diff -u -r1.50 zle_utils.c
--- Src/Zle/zle_utils.c	20 Apr 2008 21:25:28 -0000	1.50
+++ Src/Zle/zle_utils.c	21 Apr 2008 10:08:58 -0000
@@ -591,6 +591,7 @@
 {
     int i;
 
+    UNMETACHECK();
     if (flags & CUT_RAW) {
 	i = (zlecs -= ct);
     } else {
@@ -611,6 +612,7 @@
 {
     int i = zlecs;
 
+    UNMETACHECK();
     if (!(flags & CUT_RAW)) {
 	int n = ct;
 	while (n--)
@@ -633,6 +635,7 @@
 	    shiftchars(zlemetacs -= ct, ct);
 	} else {
 	    shiftchars(zlecs -= ct, ct);
+	    CCRIGHT();
 	}
     } else {
 	int n = ct, origcs = zlecs;
@@ -640,8 +643,8 @@
 	while (n--)
 	    DECCS();
 	shiftchars(zlecs, origcs - zlecs);
+	CCRIGHT();
     }
-    CCRIGHT();
 }
 
 /**/
@@ -653,6 +656,7 @@
 	    shiftchars(zlemetacs, ct);
 	} else if (flags & CUT_RAW) {
 	    shiftchars(zlecs, ct);
+	    CCRIGHT();
 	}
     } else {
 	int origcs = zlecs;
@@ -663,8 +667,8 @@
 	ct = zlecs - origcs;
 	zlecs = origcs;
 	shiftchars(zlecs, ct);
+	CCRIGHT();
     }
-    CCRIGHT();
 }
 
 /**/
@@ -672,7 +676,8 @@
 setline(char *s, int flags)
 {
     char *scp;
-	
+
+    UNMETACHECK();
     if (flags & ZSL_COPY)
 	scp = ztrdup(s);
     else


-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


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

end of thread, other threads:[~2008-04-21 10:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-21  9:56 completing in the middle of the command line causes coredump Jun T.
2008-04-21 10:11 ` 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).