-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
net_buf_append_bytes() usage may cause a failed assertion #66870
Comments
Hi @konradderda! We appreciate you submitting your first issue for our open-source project. 🌟 Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙 |
@konradderda good catch! Would you be able to submit a fix for this? |
It was my idea at first but it's a bit tricky (if my understanding is correct):
The The possible solutions I am thinking off:
|
@konradderda @jukkar I took a quick look at the related code. Perhaps |
Describe the bug
Depending on the number of bytes provided as
net_buf_append_bytes()
's it can allocate additional buffers under the hood. However, when the buffer pool is of type 'fixed' the default allocation method within this function callsnet_buf_alloc_len()
which tries to allocate a given number of bytes and it contains an assertion which checks whether the allocated size is bigger or equal to requested one.For fixed buffer pools this assertion can be hit quite easily if the number of bytes provided to
net_buf_append_bytes()
fills more than 2 fixed buffers.To Reproduce
The following snippet presents the test case:
Expected behavior
net_buf_append_bytes()
should allocate multiplestruct net_buf
s without assertion.Impact
Current implementation may cause unexpected faults, e.g. while processing data from the network.
Additional context
This issue has a workaround - user can provide
allocate_cb
argument while callingnet_buf_append_bytes()
and provide a custom allocator but one will probably find out after debugging this issue.The text was updated successfully, but these errors were encountered: