zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] PCRE match hangs when matching U+00A0
@ 2016-09-15 13:06 Sebastian Reuße
  2016-09-15 15:25 ` Jun T.
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Reuße @ 2016-09-15 13:06 UTC (permalink / raw)
  To: zsh-workers


After enabling the shell option «rematchpcre», a zsh (ver. 5.2) match
freezes when the matched string contains the character «NO-BREAK SPACE»
(U+00A0).

This may be reproduced by running the following:

    setopt rematchpcre
    s=$(echo -en \\ua0)
    [[ $s =~ . ]]

This occurred while using the en_US.utf-8 locale.

The hang seems to arise from an infinite loop at pcre.c:202
(zpcre_get_substrings). At least gdb never showed zsh returning from
this stack frame. A typical backtrace after interrupting the loop is:

	#0  mb_metacharlenconv_r (s=0x716542 "\240b", wcp=0x0, mbsp=0x6d8f28 <mb_shiftstate>) at utils.c:4988
	#1  0x00000000004a7143 in mb_metacharlenconv (s=0x716542 "\240b", wcp=0x0) at utils.c:5031
	#2  0x00007ffff5eec71d in zpcre_get_substrings (arg=0x716540 "a b", ovec=0x7165e0, ret=1, matchvar=0x7ffff5eed0df "MATCH", substravar=0x7ffff5eed0e5 "match", want_offset_pair=0, matchedinarr=0, want_begin_end=1) at pcre.c:204
	#3  0x00007ffff5eecf4b in cond_pcre_match (a=0x7ffff7ff2778, id=0) at pcre.c:389
	#4  0x0000000000426574 in evalcond (state=0x7fffffffdab0, fromtest=0x0) at cond.c:155
	#5  0x0000000000433d5a in execcond (state=0x7fffffffdab0, do_exec=0) at exec.c:4530
	#6  0x000000000042a42d in execsimple (state=0x7fffffffdab0) at exec.c:1131
	#7  0x000000000042a7a2 in execlist (state=0x7fffffffdab0, dont_change_job=0, exiting=0) at exec.c:1255
	#8  0x000000000042a14a in execode (p=0x7ffff7ff25e8, dont_change_job=0, exiting=0, context=0x4b17b7 "toplevel") at exec.c:1075
	#9  0x000000000044b8a9 in loop (toplevel=1, justonce=0) at init.c:208
	#10 0x000000000044f144 in zsh_main (argc=2, argv=0x7fffffffdd88) at init.c:1680
	#11 0x000000000040f366 in main (argc=2, argv=0x7fffffffdd88) at ./main.c:93

While stepping through, I’ve also noticed that mb_metacharlenconv_r hits:

	4991 	return 0;		/* Probably shouldn't happen */

Best regards,

Sebastian Reuße


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

* Re: [BUG] PCRE match hangs when matching U+00A0
  2016-09-15 13:06 [BUG] PCRE match hangs when matching U+00A0 Sebastian Reuße
@ 2016-09-15 15:25 ` Jun T.
  2016-09-15 16:23   ` Sebastian Reuße
  0 siblings, 1 reply; 3+ messages in thread
From: Jun T. @ 2016-09-15 15:25 UTC (permalink / raw)
  To: Sebastian Reuße, zsh-workers


2016/09/15 22:06, Sebastian Reuße <seb@wirrsal.net> wrote:

> This may be reproduced by running the following:
> 
>    setopt rematchpcre
>    s=$(echo -en \\ua0)
>    [[ $s =~ . ]]

This problem has been fixed by commit 5eae5b58, but not yet in the
latest release. Could you please try the git HEAD if possible?

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

* Re: [BUG] PCRE match hangs when matching U+00A0
  2016-09-15 15:25 ` Jun T.
@ 2016-09-15 16:23   ` Sebastian Reuße
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Reuße @ 2016-09-15 16:23 UTC (permalink / raw)
  To: Jun T.; +Cc: zsh-workers


Hello Jun,

Jun T. <takimoto-j@kba.biglobe.ne.jp> writes:

>> This may be reproduced by running the following:
>>
>>    setopt rematchpcre
>>    s=$(echo -en \\ua0)
>>    [[ $s =~ . ]]
>
> This problem has been fixed by commit 5eae5b58, but not yet in the
> latest release. Could you please try the git HEAD if possible?

I built Zsh from the current HEAD and indee the issue does not come up
there. Thank you kindly for the pointer.

Best regards,
SR


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

end of thread, other threads:[~2016-09-15 16:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15 13:06 [BUG] PCRE match hangs when matching U+00A0 Sebastian Reuße
2016-09-15 15:25 ` Jun T.
2016-09-15 16:23   ` Sebastian Reuße

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