Skip to content

[BUG][3.1] Infinite Loop/OOM in generate_wrapper_functions with a static method override #6704

@pilleye

Description

@pilleye

Describe the bug

Overriding a static method in a child class causes an infinite loop in generate_wrapper_functions, where entry.prev_entry == entry.

This issue only exists with 3.1/master and the C++ backend. Not reproducible on 3.0 or the 3.1 with the C backend.

Code to reproduce the behaviour:

Cherry-pick this commit: pilleye@dbeb85b

This issue only exists on 3.1/master with the C++ backend:

python runtests.py -3 --backends cpp -vv static_method_inheritance

Minimal repro:

cdef class Foo:
    @staticmethod
    cdef Foo meth(Foo this):
        return Foo()

cdef class OtherFoo(Foo):
    @staticmethod
    cdef OtherFoo meth(Foo this):
        return OtherFoo()

Expected behaviour

Should either not infinite loop or have validation against unexpected inputs.

OS

Reproducible on Linux and Mac, don't have access to a Windows machine.

Python version

3.12 and 3.13

Cython version

3.1/master

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions