Skip to content

Infinite Regex search #125814

@jvahue

Description

@jvahue

Bug report

Bug description:

The following regular expression never seems to terminate when run against the second element in the list (data0) below. Notice the only difference is at the very end of the second string ACARSMgr.c vs. the first string has A429Recv.c which matches, the second should not match and terminate. If you run each string individually the first string terminates with a match and the second never finished ... at least while I waited (5+ minutes). I know the regex is a little gnarly, but the compiler did not complain so I assume it is valid. I tried it at regex101.com and most things failed except Go and Rust, others timed out

# Add a code block here, if required
import re
descriptionRe = re.compile(
"Ignoring return value of function '.*?\\((?:(?:struct |enum )?.*?[, ]?)+\\)' \\(compare with ([Ll]ine[ \\t]+[0-9 ]+|[Ll]ines[ \\t]+[0-9, ]+), file <srcRoot>\\\\Utility\\.h, module <srcRoot>\\\\A429Recv\\.c\\)"
)
>>> data0 = [
"Ignoring return value of function 'strncpy_safe(char *, long, const char *, long)' (compare with line 59, file <srcRoot>\\Utility.h, module <srcRoot>\\A429Recv.c)", 
"Ignoring return value of function 'strncpy_safe(char *, long, const char *, long)' (compare with line 59, file <srcRoot>\\Utility.h, module <srcRoot>\\ACARSMgr.c)"
]
data = [i for i in data0 if descriptionRe.search(i)]

CPython versions tested on:

3.10, 3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtopic-regextype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions