Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-8637

Got error 'pcre_exec: Internal error (-8)' from regexp

    Details

    • Type: Bug
    • Status: Confirmed
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0.21, 10.1, 10.0
    • Fix Version/s: 10.1, 10.0
    • Component/s: None
    • Labels:
      None

      Description

      Under some conditions, the regexp function will raise a warning about some internal error:

      MariaDB [(none)]> SELECT 'mail@abcdefghijklmnopqr. com' REGEXP '@([[:alnum:]]*|[-]*|[.]*)*[.](com|net|us|tv|vg|qs|org|cc|tc|info|ws|ms|biz|bz|net|edu|es|fr|ru|nl|it|de|am|cl)';
      +--------------------------------------------------------------------------------------------------------------------------------------------------------+
      | 'mail@abcdefghijklmnopqr. com' REGEXP '@([[:alnum:]]*|[-]*|[.]*)*[.](com|net|us|tv|vg|qs|org|cc|tc|info|ws|ms|biz|bz|net|edu|es|fr|ru|nl|it|de|am|cl)' |
      +--------------------------------------------------------------------------------------------------------------------------------------------------------+
      |                                                                                                                                                      0 |
      +--------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set, 1 warning (0.18 sec)
      
      MariaDB [(none)]> SHOW WARNINGS;
      +---------+------+--------------------------------------------------------+
      | Level   | Code | Message                                                |
      +---------+------+--------------------------------------------------------+
      | Warning | 1139 | Got error 'pcre_exec: Internal error (-8)' from regexp |
      +---------+------+--------------------------------------------------------+
      1 row in set (0.00 sec)
      

      It might be related to string length. Changing the length of the string makes the message go away:

      MariaDB [(none)]> SELECT 'mail@abcdefghijklmnopq. com' REGEXP '@([[:alnum:]]*|[-]*|[.]*)*[.](com|net|us|tv|vg|qs|org|cc|tc|info|ws|ms|biz|bz|net|edu|es|fr|ru|nl|it|de|am|cl)';
      +-------------------------------------------------------------------------------------------------------------------------------------------------------+
      | 'mail@abcdefghijklmnopq. com' REGEXP '@([[:alnum:]]*|[-]*|[.]*)*[.](com|net|us|tv|vg|qs|org|cc|tc|info|ws|ms|biz|bz|net|edu|es|fr|ru|nl|it|de|am|cl)' |
      +-------------------------------------------------------------------------------------------------------------------------------------------------------+
      |                                                                                                                                                     0 |
      +-------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.14 sec)
      

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            serg Sergei Golubchik added a comment -

            Just FYI:
            The error is

            #define PCRE_ERROR_MATCHLIMIT       (-8)
            

            and it means

            man pcreapi
                   Internally,  pcre_exec() uses a function called match(), which it calls
                   repeatedly (sometimes recursively). The limit  set  by  match_limit  is
                   imposed  on the number of times this function is called during a match,
                   which has the effect of limiting the amount of  backtracking  that  can
                   take place. For patterns that are not anchored, the count restarts from
                   zero for each position in the subject string.
            ...
                   The  default  value  for  the  limit can be set when PCRE is built; the
                   default default is 10 million, which handles all but the  most  extreme
                   cases.  You  can  override  the  default by suppling pcre_exec() with a
                   pcre_extra    block    in    which    match_limit    is    set,     and
                   PCRE_EXTRA_MATCH_LIMIT  is  set  in  the  flags  field. If the limit is
                   exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
            
            Show
            serg Sergei Golubchik added a comment - Just FYI: The error is #define PCRE_ERROR_MATCHLIMIT (-8) and it means man pcreapi Internally, pcre_exec() uses a function called match(), which it calls repeatedly (sometimes recursively). The limit set by match_limit is imposed on the number of times this function is called during a match, which has the effect of limiting the amount of backtracking that can take place. For patterns that are not anchored, the count restarts from zero for each position in the subject string. ... The default value for the limit can be set when PCRE is built; the default default is 10 million, which handles all but the most extreme cases. You can override the default by suppling pcre_exec() with a pcre_extra block in which match_limit is set, and PCRE_EXTRA_MATCH_LIMIT is set in the flags field. If the limit is exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.

              People

              • Assignee:
                bar Alexander Barkov
                Reporter:
                GeoffMontee Geoff Montee
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: