unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: liqingqing <liqingqing3@huawei.com>
To: "Paul Eggert" <eggert@cs.ucla.edu>, "Tim Rühsen" <tim.ruehsen@gmx.de>
Cc: <libc-alpha@sourceware.org>, Florian Weimer <fweimer@redhat.com>,
	"Carlos O'Donell" <carlos@redhat.com>,
	Hushiyuan <hushiyuan@huawei.com>, Liusirui <liusirui@huawei.com>
Subject: Re: question about regex
Date: Fri, 3 Jan 2020 16:09:45 +0800	[thread overview]
Message-ID: <377311fb-fdf3-6467-3b48-28404d8c3326@huawei.com> (raw)
In-Reply-To: <05dfac46-6cf3-1f5d-14e7-3c8b07b2093e@cs.ucla.edu>



On 2020/1/3 6:14, Paul Eggert wrote:
> On 1/2/20 8:16 AM, Tim Rühsen wrote:
>> Meanwhile grep (or libc) seems to exit gracefully:
> 
> Yes, there's no core dump if the operating system supports stack overflow detection that grep can use. The problem occurs only on OSes that don't do that, or on apps that don't try to detect stack overflow and simply dump core (or worse).
> 
> On 1/2/20 2:54 AM, liqingqing wrote:
> 
>> do we have any plan or good ways to fix up the bug as below
> 
> The best way would be to fix bug#24269, i.e., fix the glibc regex code so that it doesn't blow the stack. If you could write a patch for this bug (something that doesn't hurt performance for ordinary regexps), that would be welcome.
> 
> For that particular test case, you can use an OS that does proper stack overflow checking that grep can use.

thank you Tim and Paul for your reply.  I used the "sed" command with some similar regulator expression and the  stack overflow can also be repeated.
[root@localhost liqingqing]# sed --version
sed (GNU sed) 4.5
echo A  | sed '/\(\)\(\1\1\)*/p'
Segmentation fault (core dumped)


and i use python to test, seems like the result is ok。i really want to fix this bug, but now i'm not knowing too match about this module.
so, expected for some guy's solution, thanks.

the python test:
[root@localhost liqingqing]# python
Python 2.7.15 (default, Jul 22 2019, 00:00:00)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>  m=re.match("()(\\1\\1)*", "A", 0)
  File "<stdin>", line 1
    m=re.match("()(\\1\\1)*", "A", 0)
    ^
IndentationError: unexpected indent
>>> import re
>>>  m=re.match("()(\\1\\1)*", "A", 0)
  File "<stdin>", line 1
    m=re.match("()(\\1\\1)*", "A", 0)
    ^
IndentationError: unexpected indent
>>> m=re.match("()(\\1\\1)*", "A", 0)
>>> m.group(0)
''
>>> m.group(1)
''
>>> m.group(2)
''
>>> m.group(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: no such group
>>> m=re.match("A", "A", 0)
>>> m.group(3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IndexError: no such group
>>> m.group(0)
'A'


  reply	other threads:[~2020-01-03  8:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-14  8:44 [discuss] iconv: what's the purpose of the mtrace in the tst-iconv2.c liqingqing
2020-01-02 10:54 ` question about regex liqingqing
2020-01-02 16:16   ` Tim Rühsen
2020-01-02 22:14     ` Paul Eggert
2020-01-03  8:09       ` liqingqing [this message]
2020-01-20 10:41         ` liqingqing
2020-01-20 19:25           ` Paul Eggert
2020-01-21  1:15             ` liqingqing
2020-01-21  8:57               ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=377311fb-fdf3-6467-3b48-28404d8c3326@huawei.com \
    --to=liqingqing3@huawei.com \
    --cc=carlos@redhat.com \
    --cc=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=hushiyuan@huawei.com \
    --cc=libc-alpha@sourceware.org \
    --cc=liusirui@huawei.com \
    --cc=tim.ruehsen@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).