-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Description
Describe the bug
Using current in-tree LwM2M client sample (samples/net/lwm2m_client) with overlay-dtls.conf, results in a crash due to how TLS handshake is implemented in the socket APIs.
For UDP, the TLS handshake is initiated during the first send(), for TCP it's started at connect(). In the LwM2M engine the socket is added to a poll() loop after connect() and this seems to be what is causing the crash. If I re-order the addition of the socket to the poll() loop to after the first send(), the crash goes away (such as https://github.com/foundriesio/zephyr/commit/9004322201131cf873e00611a9ddd2e3f38088e9)
To Reproduce
Steps to reproduce the behavior:
- (in another window) setup net-tools for qemu
- (in another window) start local Leshan (LwM2M server)
- cd samples/net/lwm2m_client
- mkdir build; cd build
- cmake -DBOARD=qemu_x86 -DOVERLAY_CONFIG=overlay-dtls.conf
- make run
Expected behavior
Expect to be able to add the socket to the poll() loop prior to send() and not have a crash in the LwM2M engine.
Impact
This behavior seems incorrect atm. It's a complexity, if the developer needs to know not to poll() on a socket until the first send() (for UDP).
Environment (please complete the following information):
- OS: Arch Linux
- Zephyr SDK
- Master branch @ d2886ab