Skip to content

JIT keeps a capture returned from an abandoned (*ACCEPT) subroutine attempt #1047

Open

Description

@ybai08

Found while working on #1046. With JIT, a group returned through a capture list ((?&name(N))) can keep the value it had in an attempt of the called group that was later abandoned. Reproducer from @NWilson in #1046:

/^(?:(?&r(2))X|a)(?(2)Y|b)$(?(DEFINE)(?<r>(a)(*ACCEPT)x))/
    ab
    aY

pcre2test output (main at 9b338eb, CMake Release build, JIT on, macOS arm64):

/^(?:(?&r(2))X|a)(?(2)Y|b)$(?(DEFINE)(?<r>(a)(*ACCEPT)x))/jit
    ab
No match
    aY
 0: aY
 1: <unset>
 2: a

The first alternative (?&r(2))X fails (no X after the returned a), so the second alternative a matches and group 2 should be unset at the (?(2)…) condition: ab should match and aY should not. With JIT, group 2 keeps a from the abandoned first alternative.

The interpreter on main fails on this pattern with error -44 (that is what #1046 fixes); with #1046 it matches ab and rejects aY.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions