casaroli opened a new pull request, #21508:
URL: https://github.com/apache/nuttx/pull/21508

   ## Summary
   
   Since #21492, the error path of `local_sendmsg()` runs, and it can hang. 
With an accepted stream socket: `sendmsg()` with `SCM_RIGHTS` blocks on a full 
pipe, and the peer closes. `local_free()` of the peer releases the queued files 
and clears `lc_peer`, `sendmsg()` gets `EPIPE`, and `local_freectl()` takes the 
sender as the peer. There `lc_cfpcount` is 0, so `--lc_cfpcount` reads 
`lc_cfps[65535]`.
   
   This PR releases the files only if the peer is the same as when they were 
queued, and stops when `lc_cfpcount` is 0, because the receiver can take them 
first.
   
   ## Impact
   
   Only `CONFIG_NET_LOCAL_SCM`. A failed send with control files on a live peer 
behaves as before.
   
   ## Testing
   
   A test program: `connect()` and `accept()`, the accepted socket fills the 
pipe, `sendmsg()` with `SCM_RIGHTS` blocks, another thread closes the peer. 
qemu-armv8a under QEMU, GCC 14.2:
   
   | | master | this PR |
   |---|---|---|
   | qemu-armv8a:nsh, `CONFIG_DEBUG_FEATURES` off | `EPIPE`, then the program 
never ends and no prompt | `EPIPE`, the program ends |
   | qemu-armv8a:knsh | the same with #21492 merged on an earlier master | 
`EPIPE`, the program ends |
   
   ostest status 0 on qemu-armv8a:nsh with this PR.
   
   Not run: protected builds and other architectures. The change is in common 
code.
   
   No documentation change: Documentation/ does not describe this path.
   


-- 
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