Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Incorrect reference handling in _arraycore initialization failure paths

Đã đóng
#5,271 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ó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
58/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
c, numpy, python
Lĩnh vực
backend, bioinformatics

Hướng nghiên cứu

Bắt đầu trong Bio/Align/substitution_matrices/_arraycore.c và lần theo mọi đường dẫn lỗi khởi tạo sau khi lấy numpy.ndarray. Tái hiện các trường hợp thiếu thuộc tính và không phải kiểu trong một tiến trình CPython mới với một mô-đun numpy stub, sau đó xác minh rằng các tham chiếu tạm thời được cân bằng và việc khởi tạo thành công chuyển quyền sở hữu đúng cách.

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

Mô tả

This issue does not affect users with working NumPy installations, the affected code runs only when NumPy initialization fails. It is a defensive hardening opportunity I encountered while chasing a separate memory issue through my project's dependencies.

The affected file is Bio/Align/substitution_matrices/_arraycore.c on the current Biopython master branch.

Expected behaviour

If numpy.ndarray is missing, invalid, or unsuitable as a base type, _arraycore should abort initialization while releasing exactly the temporary references it owns.

Actual behaviour

The initializer decrements the NumPy module reference after retrieving numpy.ndarray, then decrements the same reference again when the attribute is missing or is not a type. Other early returns can retain the temporary numpy.ndarray reference.

This can corrupt or imbalance CPython reference counts during failed module initialization.

Steps to reproduce

Load _arraycore in a fresh CPython process with a stub numpy module where ndarray is either missing or not a type. Both cases exercise the incorrect cleanup paths.

I have a tested fix ready that balances the temporary references and uses PyModule_AddType for the successful ownership transfer. I can open a pull request if the maintainers would like this failure path hardened.

Ngôn ngữ chính
Python
Star
5.2k
Fork
2k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
12

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

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 biopython/biopython

Tất cả issue của biopython/biopython

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.