← index #5487Issue #4112
Related · high · value 2.430
QUERY · ISSUE

MICROPY_PORT_DEINIT_FUNC called after gc_sweep_all

openby amirgonopened 2020-01-03updated 2020-01-07

I'm using MICROPY_PORT_DEINIT_FUNC to release hardware resources upon soft reset.
Unfortunately, it's called only after gc ram is deallocated by gc_sweep_all.
My port uses gc allocated ram, and when MICROPY_PORT_DEINIT_FUNC is called it's too late, gc ram was already deallocated.

https://github.com/micropython/micropython/blob/10709846f38f8f6519dee27694ce583926a00cb9/ports/esp32/main.c#L145-L153

Is there any particular reason gc_sweep_all is called before mp_deinit?
Is it reasonable to move gc_sweep_all after mp_deinit?

CANDIDATE · ISSUE

When calling MICROPY_PORT_DEINIT_FUNC, tests for MICROPY_PORT_INIT_FUNC instead

closedby pfalconopened 2018-09-09updated 2018-09-10

@stinos this line https://github.com/micropython/micropython/commit/5ed284a15e028e0435f3b6e0773e14225d8f165d#diff-1c5b9ab6f204d3f8724a0168cc50b868R96 in 5ed284a15e : As you can see, it tests for INIT when calling DEINIT. That's either typo or thinko. It's confusing, and why require a port to define INIT if it just wants to have DEINIT? Can you please take care of that?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied