Skip to content

RecursionError in pyclbr.readmodule_ex #103864

Closed as not planned
Closed as not planned
@baltsers

Description

@baltsers

Bug report

We did a fuzzing test on Python3.9.15, a recursion error happened.

from pyclbr import *
import pyclbr
import io
import tokenize
from token import DEDENT
from token import NAME
from token import OP

class demoCls():

    def __init__(self):
        pass

    def demoFunc(self, arg1,arg2):
        try:
            ret = pyclbr.readmodule_ex(arg1,arg2)
        except (AttributeError, ImportError, ModuleNotFoundError, OSError, StopIteration, TypeError, ValueError, tokenize.StopTokenizing, tokenize.TokenError):
            pass


module = '.'* 100_100
path = None
dc = demoCls()
dc.demoFunc(module, path)

details

Bug info

Traceback (most recent call last):
  File "/root/fuzzVuls/Python3.9.15/pyclbr.readmodule_ex/1#pyclbr#readmodule_ex.py", line 24, in <module>
    dc.demoFunc(module, path)
  File "/root/fuzzVuls/Python3.9.15/pyclbr.readmodule_ex/1#pyclbr#readmodule_ex.py", line 16, in demoFunc
    ret = pyclbr.readmodule_ex(arg1,arg2)
  File "/root/anaconda3/lib/python3.9/pyclbr.py", line 116, in readmodule_ex
    return _readmodule(module, path or [])
  File "/root/anaconda3/lib/python3.9/pyclbr.py", line 149, in _readmodule
    parent = _readmodule(package, path, inpackage)
  File "/root/anaconda3/lib/python3.9/pyclbr.py", line 149, in _readmodule
    parent = _readmodule(package, path, inpackage)
  File "/root/anaconda3/lib/python3.9/pyclbr.py", line 149, in _readmodule
    parent = _readmodule(package, path, inpackage)
  [Previous line repeated 993 more times]
  File "/root/anaconda3/lib/python3.9/pyclbr.py", line 140, in _readmodule
    if module in sys.builtin_module_names and inpackage is None:
RecursionError: maximum recursion depth exceeded in comparison

My environment

CPython: 3.9.15
Ubuntu: 18.0.4 (x86 64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirpendingThe issue will be closed if no feedback is provided

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions