Hi,

I noticed that both the armv7m and x86 port of nuttx's signal sending
procedure cannot handle nested signals.

I am wondering that in the up_sigdeliver functions.
A task A, being signaled, is possibile to be switch-out because of
  1. calling syslog via sinfo
  2. interrupts

A newly switched in task might send a second signal to the task A.
In such case, the saved instruction pointer value in the TCB might get
overwritten, causing a consecutive incorrect execution path when
returning tho the previous signal.

Am I correct or did I missed something here?
Nest edsignals should not be possible even if the task is suspended.  Signal delivery is managed by sched/signal/sig_deliver.c.  An overview would be like:

Line 77:

      /* Loop while there are signals to be delivered */

      for (; ; )
        {
          /* Test if this task is already handling a signal (we don't
   permit
           * nested signals on the same thread).
           */

          flags = enter_critical_section();
          if ((stcb->flags & TCB_FLAG_SIGNAL_ACTION) != 0)
            {
              /* Yes.. then we must wait for the signal handler to
   return */

              leave_critical_section(flags);
              break;
            }

Line 105:

          /* Indicate that a signal is being delivered */

          stcb->flags |= TCB_FLAG_SIGNAL_ACTION;

The the signal is processed outside of the critical section.  If the signal handler is suspended while processing, then TCB_FLAG_SIGNAL_ACTION will be set and if nxsig_deliver is called again to deliver a signal to this same task, it will return with doing anything.

When the signal handler returns, we will be back within the critical section and cannot be suspended.  Then at line 193:

          stcb->flags       &= ~TCB_FLAG_SIGNAL_ACTION;

Then it loops to try the next signal.

Where do you see a problem in this?

Greg

Reply via email to