Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thequod.de; h=
	content-type:content-type:mime-version:user-agent:date:date
	:message-id:subject:subject:from:from:received:received; s=
	postfix2; t=1464558121; bh=Ah1cwVt+bWzlYOqAVHyolrv+J801yxKjXceDp
	a3QAXY=; b=KAYrriD6XfgLiOySDBXhfWpWAXHAhCIdT9KI5vRZa3zbz1cABiuVz
	VMBfl8uS4cXWwdK8x6nPKSd6ZTZ7iMO5ykXTPUsEyYgEHbf86PNnudn+ATnlXc3a
	ZKIDrH7vqPonGyBJg5L6ab0KSGlc04iHAnXHrMysI3WT6GqFTW5mYM=
To: Zsh Hackers' List <zsh-workers@zsh.org>
From: Daniel Hahler <genml+zsh-workers@thequod.de>
Subject: Crash with zle-isearch-update and
 history-incremental-pattern-search-backward
Message-ID: <5df377c4-82bc-e0bc-7e9d-4b3bd23803b5@thequod.de>
Date: Sun, 29 May 2016 23:41:57 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.1.0
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
 protocol="application/pgp-signature";
 boundary="qDG4uPobxKJfolUGSotAht8x414VeE9m5"
X-Seq: zsh-workers 38553

--qDG4uPobxKJfolUGSotAht8x414VeE9m5
Content-Type: multipart/mixed; boundary="EvRXCHUDfx9GurG2QOVBhtT0CRa9PKSqC"
From: Daniel Hahler <genml+zsh-workers@thequod.de>
To: Zsh Hackers' List <zsh-workers@zsh.org>
Message-ID: <5df377c4-82bc-e0bc-7e9d-4b3bd23803b5@thequod.de>
Subject: Crash with zle-isearch-update and
 history-incremental-pattern-search-backward

--EvRXCHUDfx9GurG2QOVBhtT0CRa9PKSqC
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

I'm seeing the following crash with Ctrl-R (bindkey "^R"
history-incremental-pattern-search-backward), when searching for
e.g. "ssh*sl".  It crashes after no more matches are found, and then bein=
g
invoked again - after displaying "failing bck-i-search: ssh*sl".

This is related / triggered by the fact that I was not returning 1 in
the zle-isearch-update hook.

Without the "return 1":

1. Searching for "foo" will not find the 2nd result when pressing Ctrl-R
   again, but does not crash.
2. Searching for "ssh*sl" will find subsequent results, but crashes at
   the end.

It's probably related to the history itself, and not necessarily (only)
to using a wildcard, because "foo*bar" behaves not like "ssh*sl".=20

This is the relevant code I am using:

  # Display "^C" when aborting zle, but not for aborting isearch.
  # The "return 1" is necessary for subsequent C-R calls to work.
  zle-isearch-update() {
    _zsh_dont_print_ctrlc=3D1
    return 1  # This is the problematic "return".
  }
  zle -N zle-isearch-update
  zle-isearch-exit() {
    unset _zsh_dont_print_ctrlc
    return 1
  }
  zle -N zle-isearch-exit
  TRAPINT() {
    if ! (( $+_zsh_dont_print_ctrlc )); then
      print -nP %F{red}%B\^C%f%b
    fi
    return $(( 128 + $1 ))
  }

The zle hook is called via 'zlecallhook("zle-isearch-update", NULL);'.

It looks like there is some global state not handled correctly in
'execzlefunc' called from there (because commenting that will not cause t=
he
crash).

Is it required for zle-isearch-update to return 1 (or rather non-zero)?
=46rom looking at the source it does not look like the return code is
used.


The crash:

Program received signal SIGSEGV, Segmentation fault.
next =3D PATNEXT(scan);
(gdb) bt
#0  0x000000000048641d in patmatch (prog=3D0x7ffff7aad578) at pattern.c:2=
706
#1  0x0000000000485c16 in pattryrefs (prog=3D0x862950, string=3D0x7ffff7f=
e2748 "pstree -apl|less", stringlen=3D16, unmetalenin=3D0, patstralloc=3D=
0x7fffffff8480, patoffset=3D0, nump=3D0x0, begp=3D0x0,=20
    endp=3D0x0) at pattern.c:2468
#2  0x000000000048560b in pattrylen (prog=3D0x862950, string=3D0x7ffff7fe=
2748 "pstree -apl|less", len=3D16, unmetalen=3D0, patstralloc=3D0x7ffffff=
f8480, offset=3D0) at pattern.c:2213
#3  0x000000000043fa80 in igetmatch (sp=3D0x7fffffff8578, p=3D0x862950, f=
l=3D8710, n=3D0, replstr=3D0x0, repllistp=3D0x7fffffff85d0) at glob.c:294=
9
#4  0x000000000043f0ab in getmatchlist (str=3D0x9fe7d0 "pstree -apl|less"=
, p=3D0x862950, repllistp=3D0x7fffffff85d0) at glob.c:2684
#5  0x00007ffff63201a3 in doisearch (args=3D0x7ffff7feb188, dir=3D-1, pat=
tern=3D1) at zle_hist.c:1314
#6  0x00007ffff631f6d1 in historyincrementalpatternsearchbackward (args=3D=
0x7ffff7feb188) at zle_hist.c:921
#7  0x00007ffff6328f90 in execzlefunc (func=3D0x7ffff655c760 <thingies+10=
080>, args=3D0x7ffff7feb188, set_bindk=3D0) at zle_main.c:1413
#8  0x00007ffff633b6cc in bin_zle_call (name=3D0x7ffff7feb118 "zle", args=
=3D0x7ffff7feb188, ops=3D0x7fffffff89a0, func=3D0 '\000') at zle_thingy.c=
:759
#9  0x00007ffff633a630 in bin_zle (name=3D0x7ffff7feb118 "zle", args=3D0x=
7ffff7feb178, ops=3D0x7fffffff89a0, func=3D0) at zle_thingy.c:388
#10 0x000000000040fef0 in execbuiltin (args=3D0x7ffff7feb0b0, assigns=3D0=
x0, bn=3D0x7ffff655dc60 <bintab+128>) at builtin.c:484
#11 0x000000000043293f in execcmd (state=3D0x7fffffff93e0, input=3D0, out=
put=3D0, how=3D2, last1=3D2) at exec.c:3660
#12 0x000000000042cf01 in execpline2 (state=3D0x7fffffff93e0, pcode=3D195=
, how=3D2, input=3D0, output=3D0, last1=3D0) at exec.c:1758
#13 0x000000000042be40 in execpline (state=3D0x7fffffff93e0, slcode=3D515=
4, how=3D2, last1=3D0) at exec.c:1536
#14 0x000000000042b2c1 in execlist (state=3D0x7fffffff93e0, dont_change_j=
ob=3D1, exiting=3D0) at exec.c:1302
#15 0x000000000042aac2 in execode (p=3D0x861d90, dont_change_job=3D1, exi=
ting=3D0, context=3D0x4b104a "shfunc") at exec.c:1085
#16 0x00000000004367d1 in runshfunc (prog=3D0x861d90, wrap=3D0x0, name=3D=
0x7ffff7feb040 "_zsh_highlight_call_widget") at exec.c:5375
#17 0x00007ffff5cc7776 in zprof_wrapper (prog=3D0x861d90, w=3D0x0, name=3D=
0x7ffff7feb040 "_zsh_highlight_call_widget") at zprof.c:261
#18 0x0000000000436717 in runshfunc (prog=3D0x861d90, wrap=3D0x7ffff5ec83=
60 <wrapper>, name=3D0x7ffff7feb040 "_zsh_highlight_call_widget") at exec=
=2Ec:5360
#19 0x00000000004361e9 in doshfunc (shfunc=3D0x8619e0, doshargs=3D0x7ffff=
7fef128, noreturnval=3D0) at exec.c:5241
#20 0x00000000004354f9 in execshfunc (shf=3D0x8619e0, args=3D0x7ffff7fef1=
28) at exec.c:4872
#21 0x000000000043228d in execcmd (state=3D0x7fffffffa470, input=3D0, out=
put=3D0, how=3D18, last1=3D2) at exec.c:3541
#22 0x000000000042cf01 in execpline2 (state=3D0x7fffffffa470, pcode=3D67,=
 how=3D18, input=3D0, output=3D0, last1=3D0) at exec.c:1758
#23 0x000000000042be40 in execpline (state=3D0x7fffffffa470, slcode=3D614=
6, how=3D18, last1=3D0) at exec.c:1536
#24 0x000000000042b274 in execlist (state=3D0x7fffffffa470, dont_change_j=
ob=3D1, exiting=3D0) at exec.c:1294
#25 0x000000000042aac2 in execode (p=3D0x86e0d0, dont_change_job=3D1, exi=
ting=3D0, context=3D0x4b104a "shfunc") at exec.c:1085
#26 0x00000000004367d1 in runshfunc (prog=3D0x86e0d0, wrap=3D0x0, name=3D=
0x7ffff7fef070 "_zsh_highlight_widget_history-incremental-pattern-search-=
backward") at exec.c:5375
#27 0x00007ffff5cc7776 in zprof_wrapper (prog=3D0x86e0d0, w=3D0x0, name=3D=
0x7ffff7fef070 "_zsh_highlight_widget_history-incremental-pattern-search-=
backward") at zprof.c:261
#28 0x0000000000436717 in runshfunc (prog=3D0x86e0d0, wrap=3D0x7ffff5ec83=
60 <wrapper>, name=3D0x7ffff7fef070 "_zsh_highlight_widget_history-increm=
ental-pattern-search-backward") at exec.c:5360
#29 0x00000000004361e9 in doshfunc (shfunc=3D0x86e480, doshargs=3D0x0, no=
returnval=3D1) at exec.c:5241
#30 0x00007ffff6329316 in execzlefunc (func=3D0x7ffff655a988 <thingies+24=
40>, args=3D0x7ffff655e370 <zlenoargs>, set_bindk=3D0) at zle_main.c:1455=

#31 0x00007ffff63280e6 in zlecore () at zle_main.c:1113
#32 0x00007ffff6328a43 in zleread (lp=3D0x6e0040 <prompt>, rp=3D0x6e0078 =
<rprompt>, flags=3D3, context=3D0, init=3D0x7ffff634f6d8 "zle-line-init",=
 finish=3D0x7ffff634f6c8 "zle-line-finish")
    at zle_main.c:1307
#33 0x00007ffff632b262 in zle_main_entry (cmd=3D1, ap=3D0x7fffffffae90) a=
t zle_main.c:2011
#34 0x000000000044f727 in zleentry (cmd=3D1) at init.c:1531
#35 0x00000000004505de in inputline () at input.c:293
#36 0x000000000045043d in ingetc () at input.c:226
#37 0x00000000004440e0 in ihgetc () at hist.c:391
#38 0x00000000004594f5 in gettok () at lex.c:611
#39 0x0000000000458c28 in zshlex () at lex.c:275
#40 0x00000000004790e2 in parse_event (endtok=3D37) at parse.c:570
#41 0x000000000044c0f7 in loop (toplevel=3D1, justonce=3D0) at init.c:146=

#42 0x000000000044fc0a in zsh_main (argc=3D1, argv=3D0x7fffffffb378) at i=
nit.c:1687
#43 0x000000000040f266 in main (argc=3D1, argv=3D0x7fffffffb378) at ./mai=
n.c:93


Thanks,
Daniel.


--EvRXCHUDfx9GurG2QOVBhtT0CRa9PKSqC--

--qDG4uPobxKJfolUGSotAht8x414VeE9m5
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAldLYiUACgkQfAK/hT/mPgDpvQCeIghO8Jv+Yn0fPZvk5+gVLgdA
GOUAoPN4gMwtyTi3TQ/6wgnQBJ/yijyY
=OzfS
-----END PGP SIGNATURE-----

--qDG4uPobxKJfolUGSotAht8x414VeE9m5--

