Skip to content

Recursive _testcapi.pyobject_vectorcall() aborts with fatal stack overflow instead of raising RecursionError in a small-stack thread #148443

Description

@ashm-dev

Reproducer

import _testcapi, threading

threading.stack_size(1 << 20)  # 1 MiB

def c_recurse(n):
    if n:
        _testcapi.pyobject_vectorcall(c_recurse, (n - 1,), ())

t = threading.Thread(target=lambda: c_recurse(13))
t.start()
t.join()

Actual result

The process aborts with:

Fatal Python error: _Py_CheckRecursiveCall: Unrecoverable stack overflow (used 1017 kB)

Expected result

RecursionError should be raised instead of aborting the process.

Notes

Lib/test/test_call.py::TestRecursion.test_super_deep expects RecursionError for deep recursion through _testcapi.pyobject_vectorcall().

Environment

  • CPython main
  • Linux x86_64
  • glibc

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

    pendingThe 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