Closed notro closed 6 years ago
The stack available is now dynamic and smaller than before by default. The default stack size likely needs to be tuned. The default is here: https://github.com/adafruit/circuitpython/blob/master/ports/atmel-samd/mpconfigport.h#L343
Please tune it using your tests and submit a PR. Thanks!
A long time ago I implemented instrumentation for measuring max stack usage in the atmel port. If you enable MICROPY_DEBUG_MODULES
in ports/atmel-samd/ mpconfigport.h
, it turns on uheap
and ustack
, and also turns on MICROPY_MAX_STACK_USAGE
, which enables ustack.max_stack_usage()
.
THis is not in the nrf
port, but it wouldn't be hard to add that.
Having said all that, I used the instrumentation when I added it, and came up with 12kB as a reasonable stack size. That includes a guard region of 1 or 2k (can't remember which).
I missed the reduction to 2kB in the latest dynamic build when I reviewed the PR. I think maybe we should bump it back up to 12kB for now, and do some more range checking when we have time.
Thanks, this turned out to be real easy to tune. This is the bare minimum to make my tests pass:
import supervisor; supervisor.set_next_stack_limit(2048 + 256 + 64)
@dhalbert That 2k doesn't include the 1k buffer or main's stack frame. The actual region is computed here: https://github.com/adafruit/circuitpython/blob/master/supervisor/shared/stack.c#L46
So, I'm happy to see it increased but I doubt we need it to be 12k.
FYI -- I started seeing this issue repeatedly on a feather_m4_express with the current master. Increasing the default stack size from 2048 to 8192 on line 343 of mpconfigport.h fixed the problem
I see the same setting in the nrf port, but it is not in the esp8266 -- is it not needed there?
This is fixed now.
I needed to rebase #1064 on yesterdays
pin->number
change and my tests started to fail:Exception:
This seems to be the minimum to trigger the exception:
ads1015slave.py:
smbusslave.py:
Importing ads1015slave inside a function fails:
Importing directly is fine:
Importing smbusslave inside a function is fine:
The tests passed when I was based on this commit: