This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Zephyr uarte library missing UART_RX_BUF_RELEASED events

I run newest nRF53 chip as of writing with 1.6.0 nRF Connect SDK from nRF Connect Toolchain manager 3.6.1 using SES 5.50c.

I use a array of 5 rx-buffers (Increased from 3 to figure out what was going on) and handle UART_RX_BUF_REQUEST and UART_RX_BUF_RELEASED events in the registered callback.
Most of the time it runs fine but during a continuous test I notice that at random intervalls it may skip a UART_RX_BUF_RELEASED event which leads my application to detect a request of using a buffer that is not yet freed. If these buffers had been allocated dynamically this would have caused a memory leak. Instead I catch it and log it while actually allowing the reassigning of already assigned buffer.

Since I use the buffers round-robin and process data (transfer to other threads) during any UART_RX_RDY events I do not miss data but this behavior is worrying.
Is there a race-condition in the library?

Parents
  • This smells like a race condition but before that can you please explain to me what the number next to "Buf FREE X" means here? Is X something that is tracked by your application or you identify the index based on the buff pointer or you identify the buffer index freed based on some other logic?

    In the above highlighted context, why does your application think that Buf Free is index 1 instead of index 0?

    It looks like two buffer request can come in succession if second buffer is already given and is full before the application can process the UART_RX_RDY/UART_RX_BUF_RELEASED events. This might be something undocumented behavior but might not necessary translate to a missed event. It is possible that the Free event got postponed and your application index tracking is now confused due to two buffer requests coming in succession.

Reply
  • This smells like a race condition but before that can you please explain to me what the number next to "Buf FREE X" means here? Is X something that is tracked by your application or you identify the index based on the buff pointer or you identify the buffer index freed based on some other logic?

    In the above highlighted context, why does your application think that Buf Free is index 1 instead of index 0?

    It looks like two buffer request can come in succession if second buffer is already given and is full before the application can process the UART_RX_RDY/UART_RX_BUF_RELEASED events. This might be something undocumented behavior but might not necessary translate to a missed event. It is possible that the Free event got postponed and your application index tracking is now confused due to two buffer requests coming in succession.

Children
No Data
Related