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
Simply allocating memory causes hard crash & board freeze on code re-upload #9162
Comments
What kind of host computer are you using and what is its version of its OS? There are issues with macOS Sonoma. |
This can happen if CP hangs and stops running the USB task. Definitely a severe bug. |
@dhalbert Originally I tested this on MacOS Monterey 12.7.4 on an 2018 Intel Mac Mini. To be sure, I've just reproduced this on Windows 10 Home (running natively on a 2012 Intel Macbook Pro, not virtualized), and the bug triggers the same there, with all the same symptoms including the code failing to upload and the CIRCUITPY drive going unresponsive. The only apparent difference is that other USB devices (e.g. mouse) don't glitch when this happens, I guess this computer might have better isolation of USB ports, or something like that. |
@tannewt Just a guess, but I am wondering if this is due to EDIT: yes, working on fixes in there. |
@raquo Thank you very much for the "always fails" test program. That was very helpful in debugging and in testing my fixes. |
@dhalbert My pleasure, thank you for the fixes! :) |
Fixed by #9169. |
CircuitPython version
Code/REPL
Behavior
When this code is first uploaded to the board, it works as expected, and prints the expected free memory in bytes:
As you see, CircuitPython reports 67K bytes of memory left.
Now, as the board is running, if you make any code change (e.g. change "INIT DONE" to "INIT DONE!") and upload it to the board, the board freezes and becomes unresponsive, with symptoms similar to what I described in #9138. Specifically:
As with #9138, the code upload fails (old code remains on the board), and now I have a board that I can't upload any code to (the bug is triggered by the code currently on the board, not by the code being uploaded). So every time I run into this, I have to erase the board's filesystem and re-upload the code.
Description
No response
Additional information
Reproduction variations:
I have a sizeable CircuitPython project that is reliably triggering this bug on every code upload. Specifically, it's my use of
audiomp3.MP3Decoder
that triggers the problem. I am instantiating MP3Decoder relatively early in the program as recommended here, and it allocates around 35K of memory, of which at least one 9K block is contiguous. I don't even get to playing any audio, it's just this one instantiation that triggers the bug.I wanted to make a small reproduction without any dependencies, and it turned out that simply allocating memory is enough, so here we are.
Of course, I understand that memory is finite, but:
a) The reproduction program is very simple, and only uses 80K memory, and
gc.mem_free()
still reports more than 60K of available memory, so I should not be running out.b) Even if memory fragmentation is an issue, I expect a
MemoryError
at runtime instead of a hard crash during code upload, that puts the board in a hard-to-recover stateThe text was updated successfully, but these errors were encountered: