This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: question about regex



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'


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]