Skip to content

alt_extended_class + lookbehind: wrong error 125 and internal error 170 crash #959

Description

@YuFuSweetie

alt_extended_class + lookbehind: wrong error 125 and internal error 170 crash

Environment

  • PCRE2 10.47 (2025-10-21)
  • Windows 11, 8-bit library, UTF+UCP enabled
  • Option: PCRE2_ALT_EXTENDED_CLASS (UTS#18 compatible character classes)

Bug 1: UTS#18 extended class + lookbehind anywhere in the pattern → compilation fails, pcre2test aborts

When PCRE2_ALT_EXTENDED_CLASS is enabled and the pattern uses a UTS#18 extended class (e.g. difference -- or union ||), the presence of any lookbehind assertion in the pattern causes compilation to fail with an internal error, and pcre2test aborts the whole run ("flash exit").

Pattern 1: difference class + negative lookbehind

/[\d--1]a(?<!x)/alt_extended_class,utf,ucp
    a

Result:

Failed: error 170 at offset 0: internal error: unknown meta code in check_lookbehinds()
** Error code 170 not implemented in error_direction().
   error_direction() should usually return '1' for newly-added errors,
   and the offset should be just to the right of the bad character.
** pcre2test run abandoned

Pattern 2: union class + empty lookbehind

/[a||b](?<=)/alt_extended_class,utf,ucp
    a

Result: same error 170, pcre2test run abandoned.

Bug 2: nested character class used in a lookbehind → error 125 "length not limited"

When a nested character class (union of classes, e.g. [12[34]]) is used in a lookbehind assertion, compilation fails with error 125, although the class matches a single character and is clearly fixed-length.

Pattern

/(?<=[12[34]])/alt_extended_class,utf,ucp
    1

Result:

Failed: error 125 at offset 0: length of lookbehind assertion is not limited
        here: |-->| (?<=[12[34...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions