Possible `NULL`-related `SystemError` when interpreter is not fully initialized

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

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

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

Hướng nghiên cứu

Read Python/import.c around lines 3921–3922 and the IMPORTLIB(interp) definition around lines 95–96 to understand how the null value reaches this path. Reproduce with the _freeze_module command shown in the issue, then check the error handling and tests for this import path. Done means the incomplete initialization case reports a clear SystemError explaining that imports are not fully initialized; the issue also mentions fixing freeze later.

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

Mô tả

interpreter-core topic-importlib type-bug

Code: https://github.com/python/cpython/blob/9f386367333f7845095d764fad3ad9b397d04672/Python/import.c#L3921-L3922

Here IMPORTLIB(interp) can be NULL under rare conditions:

https://github.com/python/cpython/blob/9f386367333f7845095d764fad3ad9b397d04672/Python/import.c#L95-L96

For example, when interpreter is not yet fully initialized.

Output:

» ./Programs/_freeze_module crash crash.py crash.h
Exception ignored in the internal traceback machinery:
SystemError: null argument to internal routine
# ...

Refs https://github.com/python/cpython/pull/161860 where I first found this case.
Refs https://github.com/python/cpython/issues/142662 where the initial reproducer was found.

I guess we should raise a different SystemError here with the text that imports are not yet fully initialized.

My proposal is to make the error message better here: it should state the interpreter is not fully initialized.

And ideally we can fix the freeze command as well later.

Ngôn ngữ chính
Python
Star
78.2k
Fork
36.6k
Merge trung bình
19 giờ 57 phút
Pull request đã merge (30 ngày)
630

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

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.