Unflushed writes to an open SD card file are lost when the VM stops
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
- 43/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend, embedded-iot
Direzione di ricerca
Start by tracing stop_mp(), gc_deinit(), and gc_sweep_all() alongside reset_port(); the issue identifies these as the shutdown path and the point where SPI may already be reset. Investigate how open files are closed and how finalizer order affects the SDCard object. Done means stopping or finishing with an open file preserves writes and does not print the empty OSError; the payload names no test file.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Claude wrote this:
CircuitPython version and board name
Adafruit CircuitPython 11.0.0-alpha.1-69-g03db5f8ca4 on 2026-10-11; Adafruit PyPortal with samd51j20
Code
import board, sdcardio, storage, time
sdcard = sdcardio.SDCard(board.SPI(), board.SD_CS)
storage.mount(storage.VfsFat(sdcard), "/sd")
log = open("/sd/LOG.TXT", "a")
i = 0
while True:
log.write("line %d\n" % i)
i += 1
if i % 100 == 0:
log.flush()
time.sleep(0.03)
Behavior
When code.py is stopped by auto-reload, or finishes with the file still open:
OSError:with no message is printed after "Code stopped by auto-reload" or "Code done running."- Lines written since the last
flush()are lost. A newly created file that was never flushed does not appear on the card at all.
Description
The file is only closed when its finaliser runs in gc_sweep_all(), from gc_deinit() in stop_mp(). By then reset_port() has already reset the SPI bus, and the SDCard object may have been finalised first, since sweep order is arbitrary. The close() in the finaliser fails, and mp_call_function_1_protected() prints the exception.
Split out from #9138, whose hard hang no longer reproduces.
- Lingua principale
- C
- Stelle
- 4.6k
- Fork
- 1.4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 161
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di adafruit/circuitpython
-
Web Workflow Locks UpApertabug esp32 web workflow
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
adafruit/circuitpython#11616 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
nordic
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
adafruit/circuitpython#11611 ·
I maintainer di solito rispondono entro 1 giorno
-
zephyr: REPL on console?Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
adafruit/circuitpython#11606 ·
I maintainer di solito rispondono entro 1 giorno
-
busio zephyr
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
adafruit/circuitpython#11605 ·
I maintainer di solito rispondono entro 1 giorno
-
busio zephyr
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
adafruit/circuitpython#11604 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di adafruit/circuitpython
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
FujiNetWIFI/fujinet-lib#186 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100