-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Safemode due to heap allocation failure (since PR#9325) #9362
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
I tried this test program, modifying it a bit to send a shorter amount of data (because |
It seems to be more complicated. Running code inside the REPL is fine, but sending code to the REPL for execution causes a memory leak:
Repeating this a few more times will eventually trigger the heap allocation failure and safemode. Some notes:
|
Think the web workflow is leaking memory? |
I am not using the web workflow. There is no |
I'm trying your |
I just released 9.1.0-rc.0 which includes #9409. |
No change. Even the mem-free figures are very similar (the first two even identical). Is there anything I can do to help debugging? I could probably create and run a debug build. |
@bablokb Thanks. We could really use a minimal example that reproduces the problem on an Adafruit or Espressif board: I don't have the Sunton board you are testing on, for instance. As I mentioned I could not reproduce the problem in the first post on a QT Py ESP32-C3. |
It is only a problem on ESP32 boards, there is no problem with ESP32-C3. I don't own an Adafruit ESP32 board, but I did try this on other ESP32-boards (with no official support for CP yet) and have the same issue. |
When I paste code to a Ctrl-E repl of the ItsyBitsy ESP32 it consistently starts dropping characters after 255 characters. After skipping about 275 characters, another 124 characters are correctly received and then 937 characters are dropped followed by another 152 properly transmitted characters, etc..... This feels to me like the flow control between the CH9102 USB-to-Serial Converter chip and the ESP32 chip isn't working. From some quick searching there are two places I found flow control being configured, /ports/espressif/common-hal/busio/UART.c and /lib/tinyusb/hw/bsp/espressif/boards/family.c. I haven't had a chance to dig into either location but I plan on looking at that code next. |
I suspect Dan has explained this to me at least once already, but all the board/chip/uart/etc combinations are too much for me to keep a handle on.... Looking at the ItsyBitsy ESP32 circuit diagram, there doesn't appear to be any hardware flow control connected between the CH9102 and ESP32 which I guess means that the ESP32 is expected to be able to keep up with the data stream. By slowing down the UART baud rate I was able to increase the number of characters that were transmitted before characters started being dropped, but I slowed it all the way down to 300 baud and still saw the dropped data behavior. I've been staring at the "paste mode" input loop in pyexec.c which must be where the data is getting lost but I can't see any issues. I'm now wondering if background tasks could be running that are interrupting the input loop but it's going to take me a bit of digging to see if that line of thought has any potential. |
Well, by disabling the character echo in the paste mode input loop, I was able to successfully paste a 12.5k python script 😁. I have to take a break for a bit, but the next step is to trace through where ever the |
I believe the paste issue I'm having is caused by heavy UART traffic and is probably unrelated to the memory issues you are now reporting. I'll open a new issue for the paste problem and reference this just in case it turns out there is some overlap. |
The BLE workflow is leaking data every reset. #9599 also crashes due to this. |
Should be fixed by #9616. Please reopen if you find otherwise. |
CircuitPython version
Code/REPL
Behavior
Safemode error-message:
Description
This is code running from the REPL. The code will work multiple times, but after a while it will crash. This is hard to reproduce, sometime two iterations are necessary, sometimes more.
Additional information
I have this problem with various ESP32 boards since #9325. When I build up to and including 7c85f6a, the problem does not exist (#9325 is the next commit).
I could not reproduce the problem with a QTPY-ESP32-C3.
I suspect this is an issue with the switch to IDF-5.2.2. I know that activating BLE consumes a lot of memory, but my code does not do a lot, it basically prints boot_out.txt to the REPL.
The text was updated successfully, but these errors were encountered: