python / python/cpython

Crash when deleting decimal.Context.rounding through the descriptor

Đang mở
#156,806 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

extension-modules type-crash
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với decimal.Context.rounding.delete và lần theo đường dẫn descriptor qua context_setround(), getround() và context_setattr(). So sánh hành vi khi xóa giữa rounding, prec, Emin, Emax, capitals và clamp; được xem là hoàn tất khi việc xóa descriptor không còn gây crash hoặc phát sinh SystemError ngoài ý muốn. PR được liên kết gh-156807 cho biết công việc đã được tiến hành.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.