Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Unflushed writes to an open SD card file are lost when the VM stops

オープン
#11,562 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
43/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, embedded-iot, python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

bug sdcardio storage

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.

主要言語
C
スター
4.6k
フォーク
1.4k
平均マージ
23時間 40分
マージ済み PR(30日)
167

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

adafruit/circuitpython のほかの issue

adafruit/circuitpython の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。