public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/86164] std::regex crashes when matching long lines
       [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
@ 2020-08-06 16:33 ` ppalka at gcc dot gnu.org
  2021-09-14  7:33 ` boris at kolpackov dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-08-06 16:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

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

* [Bug libstdc++/86164] std::regex crashes when matching long lines
       [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
  2020-08-06 16:33 ` [Bug libstdc++/86164] std::regex crashes when matching long lines ppalka at gcc dot gnu.org
@ 2021-09-14  7:33 ` boris at kolpackov dot net
  2021-09-22  9:08 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: boris at kolpackov dot net @ 2021-09-14  7:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

Boris Kolpackov <boris at kolpackov dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boris at kolpackov dot net

--- Comment #9 from Boris Kolpackov <boris at kolpackov dot net> ---
Any progress on this?

I get the segfault (due to stack overflow) with the following trivial regex:

  regex re ("#+",);
  regex_search (string (32 * 1024, '#'), re);

In comparison, MSVC's implementation crashes on much larger input (in the above
test it is still able to match 4MB string) while libc++ doesn't seem to have
any stack-related limits (I was able to match 40MB).

I see two issues here:

1. It would have been nice if implementation-related limits were reported with
an exception rather than a crash.

2. The limits seem to be really low, both practically (matching 32KB doesn't
feel unreasonable) and compared to other implementations.

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

* [Bug libstdc++/86164] std::regex crashes when matching long lines
       [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
  2020-08-06 16:33 ` [Bug libstdc++/86164] std::regex crashes when matching long lines ppalka at gcc dot gnu.org
  2021-09-14  7:33 ` boris at kolpackov dot net
@ 2021-09-22  9:08 ` redi at gcc dot gnu.org
  2021-12-16  0:05 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-09-22  9:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shaoqin2 at illinois dot edu

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 84865 has been marked as a duplicate of this bug. ***

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

* [Bug libstdc++/86164] std::regex crashes when matching long lines
       [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-09-22  9:08 ` redi at gcc dot gnu.org
@ 2021-12-16  0:05 ` redi at gcc dot gnu.org
  2021-12-16  0:08 ` redi at gcc dot gnu.org
  2023-04-09 16:02 ` nyh at math dot technion.ac.il
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-16  0:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nyh at math dot technion.ac.il

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 93502 has been marked as a duplicate of this bug. ***

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

* [Bug libstdc++/86164] std::regex crashes when matching long lines
       [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-12-16  0:05 ` redi at gcc dot gnu.org
@ 2021-12-16  0:08 ` redi at gcc dot gnu.org
  2023-04-09 16:02 ` nyh at math dot technion.ac.il
  5 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2021-12-16  0:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |semi1 at posteo dot de

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 84738 has been marked as a duplicate of this bug. ***

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

* [Bug libstdc++/86164] std::regex crashes when matching long lines
       [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-12-16  0:08 ` redi at gcc dot gnu.org
@ 2023-04-09 16:02 ` nyh at math dot technion.ac.il
  5 siblings, 0 replies; 6+ messages in thread
From: nyh at math dot technion.ac.il @ 2023-04-09 16:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

--- Comment #15 from Nadav Har'El <nyh at math dot technion.ac.il> ---
More than 5 years later, more and more projects are discovering this bug the
hard way, and moving from std::regex to boost::regex which doesn't have this
bug - boost::regex defaults to BOOST_REGEX_NON_RECURSIVE mode, which uses a
stack on the heap instead of recursion (but I don't know if the specific
examples shown the various duplicates all need this stack in practice, for
example it's unfortunate if matching " *" needs to copy the entire input string
in a stack). The latest example of this exodus is
https://github.com/scylladb/scylladb/pull/13452. 
So I think it's about time this issue is solved. Maybe even the Boost
implementation can studied for inspiration and implementation ideas?

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

end of thread, other threads:[~2023-04-09 16:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-86164-4@http.gcc.gnu.org/bugzilla/>
2020-08-06 16:33 ` [Bug libstdc++/86164] std::regex crashes when matching long lines ppalka at gcc dot gnu.org
2021-09-14  7:33 ` boris at kolpackov dot net
2021-09-22  9:08 ` redi at gcc dot gnu.org
2021-12-16  0:05 ` redi at gcc dot gnu.org
2021-12-16  0:08 ` redi at gcc dot gnu.org
2023-04-09 16:02 ` nyh at math dot technion.ac.il

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