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

   ## Summary                                                                   
  
                                                                                
  
   Fix a race in the `sigtimedwait()` wait path where a matching signal could   
  
   remain pending while the waiting task goes to sleep.                         
  
                                                                                
  
   `sigtimedwait()` publishes `sigwaitmask` before calling `nxsig_clockwait()`. 
  
   If a matching signal is queued after that publication but before the task is 
  
   moved to `TSTATE_WAIT_SIG`, the signal can remain pending while the task 
still 
   blocks waiting for it.                                                       
  
                                                                                
  
   This change rechecks the task's pending signal set inside 
`nxsig_clockwait()`  
   while interrupts are disabled. If a pending signal matches `sigwaitmask`, it 
is
   removed from the pending queue, copied into `sigunbinfo`, and returned       
  
   immediately instead of blocking the task.                                    
  
                                                                                
  
   ## Impact                                                                    
  
                                                                                
  
   This fixes a signal wait race that could cause `sigtimedwait()` to sleep 
even  
   though a waited-for signal is already pending.                               
  
                                                                                
  
   Expected impact:                                                             
  
                                                                                
  
   - prevents missed wakeups in the `sigtimedwait()` path                       
  
   - preserves normal blocking behavior when no matching signal is pending      
  
   - consumes and reports the lowest-numbered matching pending signal           
  
   - avoids changing behavior when signals are disabled                         
  
   - no API, ABI, build-system, documentation, or security impact is expected   
  
                                                                                
  
   ## Testing                                                                   
  
   
   sim/nsh


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