-
Notifications
You must be signed in to change notification settings - Fork 1.3k
don't gc_free() ringbuf if no heap; cleanup ringbuf #6214
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
Conversation
d98faf5
to
8dcbfb3
Compare
8dcbfb3
to
b9a4f7b
Compare
I think I am going to make ringbuf not have the idiosyncratic |
@jepler this is ready for review. It will go in the next 7.2.x release. |
New |
Isn't |
We were checking The fundamental bug fix here is just this commit: All the rest is fixing some other bugs, some latent, and then, being dissatisfied with Happy to discuss this tomorrow. |
Closing this to make a simpler change just for 7.2.x. Will do additional work for |
Fixes RP2040: board.UART() giving "Attempted heap allocation when VM not running." on reload #6213.
UART deinit might happen when there is no VM, during
reset_board_buses()
, so check before trying to free a UART ringbuf that is on the heap. This UART deinit possibility was introduced in Allow multiple board buses #5422.There was a lot of inconsistency about how and whether a buffer could be supplied as the UART ringbuf. Make the code consistent across multiple ports.
ringbuf_init()
should have been used several places where it was not.There is a fine distinction between the ringbuf buffer size in bytes, and its capacity in bytes, which is one less.ringbuf_init()
used to take the capacity, but I made it take the actual buffer size, because that was less confusing when passing in an existing buffer, though inconsistent withringbuf_alloc()
, which takescapacity
and then allocates a buffer of one extra byte. Some discussion here about this point: Introduced ringbuf_init to perform static buffer initialisation #5813 (comment)(EDIT) Rewrote
ringbuf
to removecapacity == size -1
limitation. Now the size is the capacity. Code is smaller and I think more readable, at the very small expense of keeping a count of used slots.I will see if this builds, and test it more tomorrow, to make sure I have the ringbuf fixes right. Draft for now.