Closed dsitelew-gcx closed 1 month ago
Hi @dsitelew-gcx! 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. π€π
@dsitelew-gcx which platform is this on?
@dkalowsk sorry, forgot to mention it, it's an nRF9160 (Arm Cortex-M33).
Honestly, looking at the code, I thought it didn't matter what platform it was.
I've reproduced the crash, the culprit turned out the be a preempted memset() during message deallocation. It should be fixed with https://github.com/zephyrproject-rtos/zephyr/pull/79847, with those fixes in place I was able to flood the server with LwM2M send messages w/o hitting the crash again (initially it crashed after a few seconds).
Describe the bug
Enabling the preemptive TX/RX threads introduces race conditions in the LwM2M engine.
Looking at the socket_loop implementation there is almost no synchronisation. For example, scheduling a message with
lwm2m_send_cb
results in a crash due to a race condition, e.g:In this case it's a NULL-pointer dereference here
To Reproduce
Sorry, no minimal reproducible code example. I think setting the
NET_TC_THREAD_PREEMPTIVE
toy
and sending a lot of messages should suffice.Expected behavior
Sorry if this is the wrong place to post this, I just wanted to warn others of a potential problem.
The configuration flag is of course marked as experimental, so there should be no expectation that everything will work as expected, but I think since it is clear that LwM2M will not work with this flag, turning it on should result in a build error until the LwM2M engine is made thread-safe.