-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix fifo memory overflow #1789
Fix fifo memory overflow #1789
Conversation
- rename wr/rd absolute to index, and rel to pointer. - fix crash with _tu_fifo_remaining() - change get_relative_pointer() to idx2ptr() and merge with _ff_mod()
- handle/fix double overflowed with write() - other minor clean upp
Looks good! Nice that the buffer would be fuzzing-proof :) Is there anything else to improve since you mentioned there would be room therefore! |
just update the PR with your feedback, thank you for reviewing. For room to improve, I feel that we could do better to simplify the current code, but it is not urgent. Like merging get_realitve_poiinter() and _ffmod() to idx2ptr(), mostly for readability and maintenance only. I will try to wrap this up soon enough. |
Just a suggestion. It might be worth enabling However that particular flag does require clang. |
yeah, this is great idea. I will check to see we could switch to clang. Unit test like fuzzing run on host, so that wouldn't be an issue at all. |
Apologies the flag is |
- remove non_used_index_space - packed overwritable with item_size
…f_count() and _ff_remaining()
… also rename to advance/backward_index
unit-test is now configured to run with clang and |
Describe the PR
While trying to fix an issue reported in #1729 (detected using fuzzing #1716). I am able to fix a couple of issues with current tusb_fifo when using with overwritable mode
Both of above cases can be reproduced/tested with 2 new unit tests. I also take the chance to add fifo implementation note (since I kind of forgot about it) to help future troubleshooting and rename absolute/relative naming to index/pointer and other minor changes. There is still room to improve fifo, thus submitted this as draft first for feedback.
ref reading: https://www.snellman.net/blog/archive/2016-12-13-ring-buffers/9
probably fix #1039 , and also related to adafruit/circuitpython#7041 since this could be the bug of cdc fifo instead of what we thought is Linux with echo mode.