casaroli commented on code in PR #21384:
URL: https://github.com/apache/nuttx/pull/21384#discussion_r4448851153


##########
drivers/rpmsg/rpmsg_port_uart.c:
##########
@@ -538,6 +542,7 @@ static void
 rpmsg_port_uart_process_rx_conn(FAR struct rpmsg_port_uart_s *rpuart,
                                 uint8_t ch)
 {
+  nxmutex_lock(&rpuart->conn_lock);

Review Comment:
   The rx thread holds `conn_lock` across `rpmsg_port_register()` (lines 557, 
565). When the name service messages of the new endpoints find no free tx 
buffer, `rpmsg_port_uart_queue_noavail()` runs `rpmsg_port_uart_rx_worker()` on 
this same thread (line 488), and a CONNACK or CONNREQ read there calls 
`rpmsg_port_uart_process_rx_conn()` again: `nxmutex_lock()` waits for the lock 
the thread already holds (a DEBUGASSERT in `nxsem_wait_slow()`, or a hang 
without DEBUG_ASSERTIONS).
   
   Fix: make `conn_lock` a recursive mutex (`rmutex_t` with 
`nxrmutex_lock()`/`nxrmutex_unlock()`), or do not hold it across 
`rpmsg_port_register()` and `rpmsg_port_unregister()`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to