Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-118681

std::regex crashes when matching long lines

Linking RHIVOS CVEs to...Migration: Automation ...SWIFT: POC ConversionSync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • None
    • gcc / libstdc++
    • None
    • No
    • None
    • rhel-pt-cpp-libs
    • None
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164
      std::regex crashes when matching long lines.

      Here is an example:

      #include <regex>
      #include <iostream>
       
      int main()
      {
          std::string s (100'000, '*');
          std::smatch m;
          std::regex r ("^(.*?)$");
      
          std::regex_search (s, m, r);
      
          std::cout << s.substr (0, 10) << std::endl;
          std::cout << m .str (1) .substr (0, 10) << std::endl;
      }
      

      It turns out that std::regex_search operator .* is implemented recursively which result in this example in a stack overflow.

      Goal

      • Investigate how much benefit we can get from small changes that just reduce stack layout.
      • Investigate replacing recursion with iteration
      • Investigate transforming NFA to DFA (probably not possible without ABI change)

              rh-ee-ppalka Patrick Palka
              araghuku Alekya Raghukula
              Jonathan Wakely Jonathan Wakely
              Vaclav Kadlcik Vaclav Kadlcik
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated: