python / python/cpython

Crash when deleting decimal.Context.rounding through the descriptor

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

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

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

説明

Crash report

What happened?
import decimal
decimal.Context.rounding.__delete__(decimal.Context())
Segmentation fault (core dumped)

context_setround() passes the value to getround(), which calls
PyUnicode_Check() on it without checking it for NULL, and the setter is
called with NULL when the attribute is deleted. Plain del ctx.rounding is
safe, because context_setattr() rejects deletion — but it is bypassed by
calling the descriptor.

The other five Context getsets do not crash, but raise SystemError:

import decimal
decimal.Context.prec.__delete__(decimal.Context())
# SystemError: ../Objects/longobject.c:577: bad argument to internal function

Same for Emin, Emax, capitals and clamp.

CPython versions tested on:

3.15, 3.14, 3.13, 3.12

Operating systems tested on:

Windows

Output from running 'python -VV' on the command line:

Python 3.12.3 (main, Jan 8 2026, 11:30:50) [GCC 13.3.0] / Python 3.14.2 (main, Dec 17 2025, 21:10:36) [MSC v.1944 64 bit (AMD64)]

Linked PRs
  • gh-156807

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

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

はじめの一歩

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

調査の方向性

decimal.Context.rounding.delete から始め、context_setround()、getround()、context_setattr() を通る descriptor の経路を追跡します。rounding、prec、Emin、Emax、capitals、clamp の削除時の動作を比較します。完了とは、descriptor の削除によってクラッシュしたり、意図しない SystemError が発生したりしなくなることです。リンクされている PR gh-156807 は、作業がすでに進行中であることを示しています。

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

評価

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

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

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