pussuw commented on issue #14448:
URL: https://github.com/apache/nuttx/issues/14448#issuecomment-2429029183

   I noticed the issue with syslog(), though in this case it causes a deadlock. 
The problem is still the same and the leaked
   resource is g_lowputs_lock.
   
   
   ```
   static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
                                       FAR const char *buffer, size_t buflen)
   {
   #  ifdef CONFIG_ARCH_LOWPUTC
     nxmutex_lock(&g_lowputs_lock);
   
     up_nputs(buffer, buflen);
   
     nxmutex_unlock(&g_lowputs_lock);
   #  endif
   
     UNUSED(channel);
     return buflen;
   }
   #endif
   ```
   
   All you need is for CPU0 to call syslog_default_write taking the 
g_lowputs_lock semaphore and CPU1 sending a signal to CPU0. When CPU0 starts 
running the signal dispatch logic it will deadlock if there is another syslog() 
call there. One example below:
   
   
https://github.com/apache/nuttx/blob/b4a6d456c99d3c3dac843f4a18f13c78afe9395a/arch/risc-v/src/common/riscv_sigdeliver.c#L55-L72
   
   This is how it looks on the terminal
   
   ```
   [CPU1] nxsig_tcbdispatch: TCB=0x80410ad0 pid=58 signo=1 code=0 value=0 
masked=NO, svcall=YES
   [CPU0] [CPU1] nxsig_tcbdispatch: TCB=0x80410ad0 pid=58 signo=2 code=0 
value=0 masked=NO, svcall=YES
   [CPU0] up_schedule_sigaction: tcb=0x80410ad0, rtcb=0x80410ad0 
current_regs=0x80413720
   [CPU0] 
   ```
   
   up_schedule_sigaction is still 


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