Repository navigation
Conversation
The coverage variant allocates the helix MP3 decoder with plain malloc(). MP3Decode() relies on the decoder state starting out zeroed, for example mainDataBytes, which is only ever added to. The espressif allocator already clears its memory for this reason (c7807cf), and the default m_malloc path returns cleared memory too. With an AddressSanitizer build, whose malloc() fills new memory with 0xbe, tests/circuitpython/issue9705.py stops in MP3Decode() with "negative-size-param" because mainDataBytes starts as 0xbebebebe. A normal build only passes because the memory it gets happens to be zero. Use calloc() so the coverage build matches the other allocators.
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.
The unix coverage variant allocates the helix MP3 decoder with plain
malloc(), butMP3Decode()expects the decoder state to start out zeroed. For example,mainDataBytesis only ever added to. The espressif allocator already clears its memory for this reason (c7807cf), and the defaultmp3_alloc()usesm_malloc_maybe(), which also returns cleared memory (MICROPY_GC_CONSERVATIVE_CLEAR).This change switches the coverage variant to
calloc().How it shows up
I built the coverage variant with AddressSanitizer, using the flags from
CI_UNIX_OPTS_SANITIZE_ADDRESSintools/ci.sh. ASan'smalloc()fills new memory with0xbe, andtests/circuitpython/issue9705.pystops on the firstget_buffer():-1094795586is0xbebebebe. The normal build passes only because the memory it gets back happens to be zero.Testing
issue9705.py.exp, apart from UBSan's reports about left shifts of negative values in the fixed-point DSP code, which this change doesn't touch.run-tests.pysuite gives 1056 passed. The only failure isissue9705.py, and that is only because of those UBSan lines.run-tests.py -d circuitpythonstill passes.Found and tested with Claude Code (Claude Opus 5.5); I reviewed the change.