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

Re: bindkey <whatever> history-beginning-search-backwards; echo $widgts = crash



On 2007-05-21 at 22:21 +0200, Maddi Kopfermann wrote:
> Hi Zsh Comrades,
> 
> Yesterday i found what it seems to be a very old bug.
> 
> bindkey <whatever> history-beginning-search-backwards &&

history-beginning-search-backwards is not a standard widget; aside from
this bug, you need to find which widget you really want.

> echo $widgets crashes zsh, it does with zsh -f.
> On #zsh Frank Terbeck had it crash even with 3.1.7. All
> versions that have history-beginning-search-backwards did
> crash, it seems.

This is a bug when there is no widget with the supplied name; the value
for the type can't be calculated.  The code which loops over the widgets
doesn't notice that the widget doesn't really exist and the code which
produces a stringification doesn't handle it.

% bindkey '^Z' fred
% ^Z
No such widget `fred'
% print ${(v)widgets}
[segfault]

The attached patch ensures that there's an appropriate value for the
key; it'll do as a work-around for now.

#0  0x0000000801918291 in widgetstr (w=0x0) at zleparameter.c:78
78          if (w->flags & WIDGET_INT)
(gdb) bt
#0  0x0000000801918291 in widgetstr (w=0x0) at zleparameter.c:78
#1  0x00000008019184f8 in scanpmwidgets (ht=0x55cd40, func=0x80069a6d0 <scanparamvals>, flags=1) at zleparameter.c:134
#2  0x000000080067229f in scanmatchtable (ht=0x55cd40, pprog=0x0, sorted=0, flags1=0, flags2=33554432, 
    scanfunc=0x80069a6d0 <scanparamvals>, scanflags=1) at hashtable.c:381
#3  0x000000080067258b in scanhashtable (ht=0x55cd40, sorted=0, flags1=0, flags2=33554432, scanfunc=0x80069a6d0 <scanparamvals>, 
    scanflags=1) at hashtable.c:444
#4  0x000000080069a959 in paramvalarr (ht=0x55cd40, flags=1) at params.c:547
#5  0x000000080069aa25 in getvaluearr (v=0x7fffffffdf40) at params.c:565
#6  0x000000080069e409 in getarrvalue (v=0x7fffffffdf40) at params.c:1862
#7  0x00000008006bda52 in paramsubst (l=0x545068, n=0x545098, str=0x7fffffffe088, qt=0, ssub=0) at subst.c:2034
#8  0x00000008006b9afa in stringsubst (list=0x545068, node=0x545098, ssub=0, asssub=0) at subst.c:193
#9  0x00000008006b9400 in prefork (list=0x545068, flags=0) at subst.c:91
#10 0x0000000800664304 in execcmd (state=0x7fffffffe650, input=0, output=0, how=18, last1=2) at exec.c:2039
#11 0x000000080066253e in execpline2 (state=0x7fffffffe650, pcode=387, how=18, input=0, output=0, last1=0) at exec.c:1343
#12 0x000000080066199c in execpline (state=0x7fffffffe650, slcode=4098, how=18, last1=0) at exec.c:1129
#13 0x0000000800661261 in execlist (state=0x7fffffffe650, dont_change_job=0, exiting=0) at exec.c:935
#14 0x0000000800660dda in execode (p=0x544f68, dont_change_job=0, exiting=0) at exec.c:793
#15 0x000000080067bd5c in loop (toplevel=1, justonce=0) at init.c:180
#16 0x000000080067ede0 in zsh_main (argc=1, argv=0x7fffffffe780) at init.c:1347
#17 0x00000000004006cb in main (argc=1, argv=0x7fffffffe780) at ./main.c:93

-Phil
diff -urp zsh-head/Src/Zle/zleparameter.c zsh-bindkey-crash/Src/Zle/zleparameter.c
--- zsh-head/Src/Zle/zleparameter.c	Tue Mar  7 13:31:44 2006
+++ zsh-bindkey-crash/Src/Zle/zleparameter.c	Mon May 21 18:37:22 2007
@@ -75,6 +75,8 @@ createspecialhash(char *name, GetNodeFun
 static char *
 widgetstr(Widget w)
 {
+    if (!w)
+	return dupstring("undefined");
     if (w->flags & WIDGET_INT)
 	return dupstring("builtin");
     if (w->flags & WIDGET_NCOMP) {


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