Skip to content

configparser: quadratic time in ParsingError.combine() when many lines fail to parse #148370

Description

@StanFromIreland

Bug report

Bug description:

Found by OSS Fuzz in #501627726.

A simplified reproducer:

import time
import configparser

for N in (5000, 10000, 20000, 40000):
    s = '[*]\n' + '=\n' * N
    p = configparser.ConfigParser(strict=False)
    t0 = time.perf_counter()
    try:
        p.read_string(s)
    except configparser.ParsingError:
        pass
    print(f'{N}: {time.perf_counter() - t0}s')

produces:

5000: 0.5495022920076735s
10000: 2.0415573030040832s
20000: 7.589155077002943s
40000: 30.856201829999918s

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

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

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions