diff options
author | Neil Ludban <neil.ludban@mantiumai.com> | 2025-01-25 16:00:24 -0500 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-02-11 12:44:48 +1100 |
commit | b11ba39c57ef6dd4d5a865464229a2aede9c825e (patch) | |
tree | 358a2526795dcb5ab474393bfc8df8597c014511 /docs/reference/pyboard.py.rst | |
parent | 11c9656fad716d42a33e9f5bc65596300d141daa (diff) | |
download | micropython-b11ba39c57ef6dd4d5a865464229a2aede9c825e.tar.gz micropython-b11ba39c57ef6dd4d5a865464229a2aede9c825e.zip |
rp2/modules: Fix memory leak and logic bug in handling of _pio_funcs.
The `rp2` package use a global dict `_pio_funcs` to populate a namespace
for `@asm_pio` functions to be executed in. That dict is not cleaned up
after use, keeping references to bound methods of a `PIOASMEmit`. By not
setting/clearing all the functions, `asm_pio_encode` unintentionally allows
the use of the old directives (harmless) as well as `jmp` (in general,
produces the wrong output).
Fix that by making sure `_pio_funcs` is returned to its original state
after using it:
- For `@asm_pio` update the target dict from `_pio_funcs` and then set
additional functions as needed, leaving `_pio_funcs` unchanged.
- For `asm_pio_encode`, borrow `_pio_funcs` to use as globals (avoiding a
bunch of memory alloc/free) but delete the instruction entries after use.
Signed-off-by: Neil Ludban <neil.ludban@gmail.com>
Diffstat (limited to 'docs/reference/pyboard.py.rst')
0 files changed, 0 insertions, 0 deletions