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

   ## Summary
   
   task: fix cu assert when use ctrl + c
   
   Backtrace:
    backtrace_unwind+0x1da/0x1dc
    sched_backtrace+0x1c/0x30
    sched_dumpstack+0x20/0x68
    _assert+0x1dc/0x45c
    __assert+0x8/0x10
    nxsem_recover+0x46/0x50
    nxtask_recover+0x14/0x20
    nxtask_exithook+0x14/0x8c
    nxtask_terminate+0x2c/0x50
    pthread_cancel+0x44/0x74
    cu_main+0x26a/0x400
    nxtask_startup+0x14/0x28
    nxtask_start+0x4a/0x64
   
   cu have two threads: cu & listener
   ```
   cu thread
   receive ctrl+c
   pthread_cancel()
    nxtask_terminate()
      enter_critical_section()
      nxsched_remove_readytorun(listener)
      keep task state to WAIT
      leave_critical_section()
                                       UART RX IRQ happens
                                       sem_post(listener)
                                         remove the sem waitlist failed
                                         but semcount++
      nxtask_recover(listener)
       nxsem_recover(listener)
       semcount < 0 assert failed
   ```
   
   Resolve:
   Swap the nxtask_recover() & nxsched_remove_readytorun()
   
   
   ## Impact
   
   nxtask_terminate 
   
   ## Testing
   
   vela boards & sim
   
   
   


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