Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Incorrect reference handling in _arraycore initialization failure paths

Chiusa
#5,271 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
c, numpy, python

Direzione di ricerca

Inizia in Bio/Align/substitution_matrices/_arraycore.c e traccia ogni percorso di errore di inizializzazione dopo aver recuperato numpy.ndarray. Riproduci i casi di attributo mancante e di non-tipo in un processo CPython nuovo con un modulo numpy stub, quindi verifica che i riferimenti temporanei siano bilanciati e che l'inizializzazione riuscita trasferisca correttamente la proprietà.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
5.2k
Fork
2k
Merge medio
1g 12h
PR unite (30g)
13

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di biopython/biopython

Tutte le issue di biopython/biopython

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.