python / python/cpython

Importing ctypes results in extra open libffi file descriptor since 3.14

Aperta
#135,893 20 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

extension-modules topic-ctypes type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug report

Bug description:

On python 3.13 (Fedora), importing ctypes results in the following output from lsfd:

python3 893377 daandemeyer    mem r-x---  REG   0:37     0  304862113 /usr/lib64/libffi.so.8.1.4
python3 893377 daandemeyer    mem r-----  REG   0:37     0  304862113 /usr/lib64/libffi.so.8.1.4
python3 893377 daandemeyer    mem r-----  REG   0:37     0  304862113 /usr/lib64/libffi.so.8.1.4
python3 893377 daandemeyer    mem rw----  REG   0:37     0  304862113 /usr/lib64/libffi.so.8.1.4

On python 3.14 (Fedora), importing ctypes results in the following output from lsfd:

python3 892407 daandemeyer      5 r-----  REG  0:238  1342       7553 /usr/lib64/libffi.so.8.2.0

This ended up breaking https://github.com/systemd/mkosi because it relied on the fact that no new regular file descriptors were opened by importing ctypes (on python 3.14 the file descriptor shows up in /proc/self/fd whereas on python 3.13 the file descriptors are memory maps which don't show up in /proc/self/fd). I searched through the commit list and couldn't find the commit that introduced this change. It also didn't seem to be documented in the release notes. Can anyone point me to the commit introducing this change and the reasoning behind it?

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia confrontando gli import di ctypes su Python 3.13 e 3.14 in Linux, usando lsfd e /proc/self/fd come nel report. Traccia la cronologia dei commit di CPython relativa alla modifica che fa apparire libffi come un normale descrittore di file, quindi determina la motivazione della modifica e se il comportamento richiede una correzione di regressione o una documentazione nelle note di rilascio. Il lavoro è completato quando la modifica e il ragionamento sono chiaramente identificati e verificati.

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

Valutazione

Stack tecnologico
python
Ambito
operating-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.