Sitelet https://github.com/python/cpython/issues/148443
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

  1. Fidget-Spinner commented on Apr 12, 2026

    @Fidget-Spinner
    Member

    I don't think this is a bug? If you set a small stack size, any program including Python will overflow.

    Each Python entry takes roughly 2kB. This doesn't count the other frames entering the Python part. So that doesn't leave Python with any space.

  2. added
    pendingThe issue will be closed if no feedback is provided
    on Apr 12, 2026
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