Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

gnrc_pktbuf_static: fix #5748 #6086

Merged
merged 1 commit into from
Dec 16, 2016

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Nov 8, 2016

I think I found the problem causing #5748 (and maybe even #4048): If the packet buffer gets full it might happen that the _unused_t segment is written to the very end, though it will overflow. This PR fixes that.

@miri64 miri64 added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Area: network Area: Networking GNRC CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 8, 2016
@miri64 miri64 added this to the Release 2016.10 milestone Nov 8, 2016
@OlegHahm
Copy link
Member

OlegHahm commented Nov 9, 2016

With +CFLAGS += -DGNRC_PKTBUF_SIZE=512 -DGNRC_IPV6_NC_SIZE=100 -DGNRC_IPV6_FIB_TABLE_SIZE=350 added to the Makefile of gnrc_networking, 200 nodes in IoT-Lab (Lille) and start one node as RPL root node, I still experience some crashes.

@miri64
Copy link
Member Author

miri64 commented Nov 9, 2016

Mh okay. Then let's postpone this one for now. I will investigate this for 2017.01.

@miri64 miri64 modified the milestones: Release 2017.01, Release 2016.10 Nov 9, 2016
@@ -437,6 +437,7 @@ static void *_pktbuf_alloc(size_t size)
DEBUG("pktbuf: no space left in packet buffer\n");
return NULL;
}
/* _unused_t struct would fit => add new space at ptr */
if (sizeof(_unused_t) > (ptr->size - size)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be if ((_unused_t != NULL) && (sizeof(_unused_t) > (ptr->size - size))), compare L454 where _first_unused = NULL;?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah no, I misread ...

@@ -447,7 +448,12 @@ static void *_pktbuf_alloc(size_t size)
}
else {
_unused_t *new = (_unused_t *)(((uint8_t *)ptr) + size);
if (prev == NULL) { /* ptr was _first_unused */

if (((((uint8_t *)new) - &_pktbuf[0]) + sizeof(_unused_t)) > GNRC_PKTBUF_SIZE) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of parens - but still not enough. ;-) Should be &(_pktbuf[0])).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? Since when?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me: since ever. ;-) Just to make clear that the address of _pktbuf[0] is meant and not the address of _pktbuf.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO that's perfectly clear, because even forgetting all about operator priorities it still wouldn't make sense to me to give & priority over [], but fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@OlegHahm
Copy link
Member

IIRC the last time we talked about this PR you wanted to look into it again or should we proceed and merge this ASAP?

@miri64
Copy link
Member Author

miri64 commented Dec 15, 2016

IIRC the last time we talked about this PR you wanted to look into it again or should we proceed and merge this ASAP?

I would rather merge it ASAP. The error with the crash on large networks seems to be unrelated.

Copy link
Member

@OlegHahm OlegHahm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@miri64 miri64 force-pushed the gnrc_pktbuf_static/fix/i5748 branch from d46c603 to 5e236cd Compare December 15, 2016 19:57
@miri64
Copy link
Member Author

miri64 commented Dec 15, 2016

Squashed

@miri64 miri64 merged commit 490b907 into RIOT-OS:master Dec 16, 2016
@miri64 miri64 deleted the gnrc_pktbuf_static/fix/i5748 branch December 16, 2016 06:18
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants