-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CIRCUITPY_PYSTACK_SIZE=4000 crashes ESP32S3 boards to safe mode #7643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On S2 I could go up to a megabyte before I added checks. I assumed I hit some interger limit there. The effective upper limit is 3700 for S2, 7000 for rp2. Currently I have covid and I am pretty much unable to fix this. However can you please find the exact value it fails on? The fix would pretty much be defining an upper limit for every mcu. If the value set is higher than that, lower it to the maximum. |
My stack depth test:
|
Rest up and get better, this functionality is awesome and is absolutely functional even with this issue. I'm not around much this weekend but I'll try and nail down the exact setting that crashes when I have a chance. Thanks SO much for this work 😁. |
On the S3 it seems that a setting of 3504 or higher will lead to a safe mode hard crash if the stack depth test is run. 3503 or lower seems stable. |
One interest would be to print out the memory address that are allocated to see what they are near. |
Built on an ESP32-S3-DevKitC-1-N8R2. The crash limit was actually a little higher but I haven't spent any time looking at that yet. I set the pystack size to 3600 and got the following trackeback:
I tried running the decode_backtrace function but the board doesn't seem to have the subprocess library baked in. I also don't know if it would be of much value anyway since the traceback is flagged as corrupted. |
I'm not real fluent in c++ pointer addresses but I used the following to print what I'm hoping is the pystack memory address: |
I think the crash makes it pretty clear that we're not checking that we're within the C stack. There is stack checking code but its probably not checking the C stack and the pystack. |
I have finished reading the cp source for all stack code (pystack, cstack, heap). |
The following build is latest master, built manually cuz I just reinstalled my desktop and was testing it.
Quite a bit faster than my pi400. Reproduced on C3, with a pystack of just 2000!!
|
It boots and works till you access that memory. Stock pystack size works just fine, so as an emergency workaround I suggest |
I'm ok disabling it for boards that crash instead of setting an arbitrary limit. |
I want to fix it so that all boards can use it to their limits. |
I managed to have it happen on S2 too, though it seems less frequent.. So it affects all esp. Also, the effective maximum on rp2 has changed. rp2 is still 100% stable.
I will look into it more. |
|
nRF doesn't have any stack checking besides what CircuitPython does. ESP has FreeRTOS to check the stack as well. I wouldn't be so sure it's |
Passes just fine. |
I have let it run for quite a while now. The pystack is not corructed and the system is stable. Uptime 6 hours. |
I am still trying my luck with However I discovered another way to reproduce this issue immediately (unless you are using debug builds):
It immediately crashes, after printing a single "Done". I have tried my luck with:
To pinpoint the faulty function, without much success. |
I have news. By editing I have toyed around with the debug uart of With pystack allocated to
( The crash looks something like:
All the above addresses are waaay off of pystack. This indicates the issue is probably elsewhere. |
Added a heap pointer print
I do not know how to decode the backtrace but some of the heap region is in there. |
The original issue description suggests that merely booting with CIRCUITPY_PYSTACK_SIZE=4000 will cause a problem on ESP32. However, most of the subsequent comments talk about running a test program that causes a stack overflow to reproduce the problem. Which one is it? |
Sir. I have no idea at all! Different esp's behave differently with this bug. Current guestimation: heap overflows to the right. |
I just grabbed the latest bits for |
PicoDVI in CP support 640x480 and 800x480 on Feather DVI, Pico and Pico W. 1 and 2 bit grayscale are full resolution. 8 and 16 bit color are half resolution. Memory layout is modified to give the top most 4k of ram to the second core. Its MPU is used to prevent flash access after startup. The port saved word is moved to a watchdog scratch register so that it doesn't get overwritten by other things in RAM. Right align status bar and scroll area. This normally gives a few pixels of padding on the left hand side and improves the odds it is readable in a case. Fixes #7562 Fixes c stack checking. The length was correct but the top was being set to the current stack pointer instead of the correct top. Fixes #7643 This makes Bitmap subscr raise IndexError instead of ValueError when the index arguments are wrong.
Guys. I have some very painful news.
>>> from time import sleep
>>> d=0
>>> a = """try:
... sleep(0.1)
... print(d)
... d += 1
... exec(a)
... except KeyboardInterrupt:
... pass
... """
>>> exec(a)
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[01:14:13.515] Disconnected |
@tannewt |
CircuitPython version
Code/REPL
Behavior
On esp32s3 boards setting CIRCUITPY_PYSTACK_SIZE=4000 causes a crash into safe mode.
A value of 3500 works fine.
Description
I've used values up to 7000 on a board with the raspberry pi RP2040 micro controller without a similar crash.
This may be a total red herring but building with micropy_stackless=1 prevents the crash, however setting CIRCUITPY_PYSTACK_SIZE > 3500 still doesn't seem to improve the stack limitations (EDIT: I'm not sure about this now, my stack depth test may have been faulty). I remember @bill88t mentioning that on some boards the parameter had an effective upper limit but I can't find the note right now. Perhaps the ESP32S3 was one of those boards.
Additional information
No response
The text was updated successfully, but these errors were encountered: