python / python/cpython

Compiler RecursionError more likely to occur in 3.13

オープン
#120,331 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

topic-parser type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

Reference: https://github.com/sympy/sympy/issues/26692

There's a long expression in sympy that's causing a RecursionError in ast.c. The source of the RecursionError is https://github.com/python/cpython/blob/ffc8e21c80627c46be7a7467ee5427924fdeb885/Python/ast.c#L217.

This seems to happen with a 3.13 debug build due to a lower recursion limit. The error doesn't happen in 3.13 release.

Interestingly, the error doesn't happen in the 3.12 debug build, even though the recursion limit appears to be the same. This leads me to believe that 3.13 is causing more recursive calls than expected. I think we should investigate why 3.13 is making additional calls and/or raise the recursion limit.

Simple repro:

import ast
contents = "x = " + " * ".join(["1"] * 2000)
result = ast.parse(contents)

On 3.12 debug, this code runs fine. On 3.13 debug, this code causes a RecursionError even when we change 2000 to 500 (leading me to believe that it is not the case that 3.13 is just adding a constant number of additional calls).

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、3.12 と 3.13 の debug ビルドで ast.parse を使って式を再現し、その後、報告された 217 行目付近の再帰チェックにある Python/ast.c を調べます。3.13 が追加の再帰呼び出しを行う理由、または再帰制限が不適切かどうかを特定します。回帰が解消され、提供された再現例がもはや失敗しないことを検証できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
compilers
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
32/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。