Unflushed writes to an open SD card file are lost when the VM stops
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 43/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 领域
- backend, embedded-iot
调研方向
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 内容生成。
描述
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 分钟
- 30 天内合并 PR
- 167
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
adafruit/circuitpython 的其他 Issue
-
难度 5/5 一周以上 新手友好度 15/100
adafruit/circuitpython#11606 ·
维护者通常 1 天内回复
-
busio zephyr
难度 5/5 一周以上 新手友好度 18/100
adafruit/circuitpython#11605 ·
维护者通常 1 天内回复
-
busio zephyr
难度 4/5 3-5 天 新手友好度 28/100
adafruit/circuitpython#11604 ·
维护者通常 1 天内回复
-
busio zephyr
难度 4/5 3-5 天 新手友好度 22/100
adafruit/circuitpython#11603 ·
维护者通常 1 天内回复
-
busio zephyr
难度 5/5 一周以上 新手友好度 15/100
adafruit/circuitpython#11602 ·
维护者通常 1 天内回复
查看 adafruit/circuitpython 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
area:gates bug good first issue
难度 1/5 1 小时以内 新手友好度 85/100
InauguralSystems/EigenScript#1782 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
fluent/fluent-bit#12579 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
obsproject/obs-studio#14036 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复