Files
micropython/ports/rp2/modules
Neil Ludban b11ba39c57 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>
2025-02-11 12:44:48 +11:00
..
2024-02-07 13:25:09 +11:00