Skip to content

Recursion check in 3.13.8 in CALL_BOUND_METHOD_GENERAL leaves stack in inconsistent state #145008

@marc-hb

Description

@marc-hb

Bug report

Bug description:

I had the same experience with this bug as with a compiler bug: I first suspected and debugged everything else than cpython. But:

   sys.setrecursionlimit(1000) # PASS
   sys.setrecursionlimit(1001) # FAIL
   sys.setrecursionlimit(1002) # PASS
   sys.setrecursionlimit(1003) # FAIL
   sys.setrecursionlimit(1004) # PASS
   sys.setrecursionlimit(1005) # FAIL
  • While it's not clear to me why some test configurations fails and others do not, the
    corruption that seems to be happening is 100% deterministic. When a test configuration fails,
    then it fails 100% of the time. Test configurations that pass, pass 100% of the time.

So, I really think this is a cpython issue now.


Simple and short reproduction steps simplified from all the trial and error in zephyrproject-rtos/west#908

git clone https://github.com/zephyrproject-rtos/west
cd west
git checkout 2d883de32f4f # today's latest version

# You MUST turn off the @pytest.mark.skipif((3, 13, 8) <= sys.version_info) I had to add in test_manifest.py not to break CI.
# See where in https://github.com/zephyrproject-rtos/west/pull/919#issuecomment-3900130946

uv python install 3.12   3.13.7 3.13.8 3.13.12   3.14
for i in          3.12   3.13.7 3.13.8 3.13.12   3.14; do
  uv run --python "$i"  pytest -k loop_detect
done

Versions from 3.13.8 to 3.13.12 FAIL odd recursion limits. All other Python versions pass.

The test fails with a very long (by design) stack trace seen here:
zephyrproject-rtos/west#908 (comment)

Then, the last frames of the stack observed with pytest --pdb makes no sense:

  1. The srp() method (Stream Reader.peek()) is called without any parameter
  2. Its default index argument is index : int = 0
  3. Inside the peek() method, the index: int parameter becomes equal to... self!!
        def peek(self, index: int = 0) -> Text:

(Pdb) p self
<ruamel.yaml.reader.Reader object at 0x7ff5ed1b9010>
(Pdb) p index
<ruamel.yaml.reader.Reader object at 0x7ff5ed1b9010>  # !!!!!

CPython versions tested on:

3.13

Operating systems tested on:

Linux, Windows, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions