You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default value of HEAP_MEM_POOL_ADD_SIZE_SOCKETPAIR (255) seems to be insufficient to create a socket_pair.
To create a socket pair using z_impl_zsock_socketpair from socketpair.c, spair_new() is executed twice. spair_new() does a malloc() of sizeof(struct spair) (148) bytes. This results in a total of 296 bytes of heap usage.
Since the heap is only 256 bytes, this will fail.
Is this derised behaviour? Or should the default size be increased?
Also, sizeof(struct spair) depends on CONFIG_NET_SOCKETPAIR_BUFFER_SIZE. Should this somehow be taken into account?
To Reproduce
There is no direct way to reproduce using the zephyr tree. I stumbled apon the issue while developing a coap_server for native_sim. The issue was introduced in 671f0f6.
Impact
Coap server thread stops running, so my device is not reachable over coap.
Environment (please complete the following information):
The default value of HEAP_MEM_POOL_ADD_SIZE_SOCKETPAIR (255) seems to be insufficient to create a socket_pair.
To create a socket pair using z_impl_zsock_socketpair from socketpair.c, spair_new() is executed twice. spair_new() does a malloc() of sizeof(struct spair) (148) bytes. This results in a total of 296 bytes of heap usage.
If there is only one entity like socketpair wanting heap, then this is indeed problem. If there are other entities adding their requirements to the heap size, then the issue is probably not seen so often.
Since the heap is only 256 bytes, this will fail.
Is this derised behaviour? Or should the default size be increased? Also, sizeof(struct spair) depends on CONFIG_NET_SOCKETPAIR_BUFFER_SIZE. Should this somehow be taken into account?
Yes, we should allocate the enough space for the two spair struct.
Would you be able to send a fix for this, so increase the default value from 255 to what ever is needed?
Also it might make sense to add build asserts in the code so that if there is not enough space allocated, then the build will fail so we can detect this issue earlier. With the build assert, we do not need to specifically check the value of CONFIG_NET_SOCKETPAIR_BUFFER_SIZE.
Describe the bug
The default value of
HEAP_MEM_POOL_ADD_SIZE_SOCKETPAIR
(255) seems to be insufficient to create asocket_pair
.To create a socket pair using
z_impl_zsock_socketpair
fromsocketpair.c
,spair_new()
is executed twice.spair_new()
does amalloc()
ofsizeof(struct spair)
(148) bytes. This results in a total of 296 bytes of heap usage.Since the heap is only 256 bytes, this will fail.
Is this derised behaviour? Or should the default size be increased?
Also,
sizeof(struct spair)
depends onCONFIG_NET_SOCKETPAIR_BUFFER_SIZE
. Should this somehow be taken into account?To Reproduce
There is no direct way to reproduce using the zephyr tree. I stumbled apon the issue while developing a
coap_server
fornative_sim
. The issue was introduced in 671f0f6.Impact
Coap server thread stops running, so my device is not reachable over coap.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: