sprint_event: avoid %hu format (unsupported by MicroPython internal printf)#888
Open
bwhitman wants to merge 1 commit into
Open
sprint_event: avoid %hu format (unsupported by MicroPython internal printf)#888bwhitman wants to merge 1 commit into
bwhitman wants to merge 1 commit into
Conversation
PRIu16 expands to "%hu", which MicroPython's internal printf (mp_vprintf, used when MICROPY_USE_INTERNAL_PRINTF=1 overrides snprintf) does not support: it hits assert(*fmt == '%' || !"unsupported fmt char") in py/mpprint.c and aborts on debug builds. This fires in any MicroPython port that links AMY and binds snprintf to the internal implementation (e.g. Tulip Linux desktop, or the AMYboard VCV Rack plugin build) whenever sprint_event runs — amy_dump_state(), update_sketch_knobs(), etc. Print the osc field with %u and an unsigned cast instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
🎛️ AMY HW CI (AMYboard bench)Flashed this PR's AMY (LoadTestChord: 6-voice Juno ✅ PASS — the bench ran the test to completion.
Full chord settled render μs: 3676 (was 3672, Δ +0.1%) (peak 3691, 39 samples) ⬇️ Artifacts: serial log · load trace · report Self-hosted bench (amyboardci). FAIL means only that the test could not run — the load values are informational, with no threshold and no audio compare. See |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
sprint_eventinsrc/patches.cprinted theoscfield withPRIu16, which expands to%hu. MicroPython's internal printf (mp_vprintf) has nohlength-modifier support, so in any MicroPython port whereMICROPY_USE_INTERNAL_PRINTF=1overridessnprintf(the default;micropython/shared/libc/printf.croutes it intomp_vprintf), formatting reachesassert(*fmt == '%' || !"unsupported fmt char")inpy/mpprint.cand aborts on debug builds — triggered by anything that serializes events:tulip.amy_dump_state(),amyboard.update_sketch_knobs(), etc.Affected in practice: Tulip Linux desktop builds and the AMYboard VCV Rack plugin build. Tulip macOS desktop happens to be immune: Darwin's fortify headers rewrite
snprintfcalls to___snprintf_chk(system libc) regardless of-U _FORTIFY_SOURCE, bypassing the MicroPython override — verified live at the desktop REPL.Fix
Print the osc field with
%uand an(unsigned)cast (varargs promoteuint16_ttointanyway, so this is value-identical). These were the only two%husites reachable throughsnprintfin AMY; all other formats used (%d/%uvia 32-bit PRI macros,%.3f,%s) are supported bymp_vprintf.Testing
make test: 109 tests pass.🤖 Generated with Claude Code