Re: Threads signalling issue [was RE: threads change]

[email protected] (Nicholas Clark)
Newsgroups perl.perl5.porters,perl.ithreads
Message-ID <[email protected]>
Ignoring SMP write issues, I think that this code has a race condition
already:

Thread 1:                                      Thread 2:
void
Perl_despatch_signals(pTHX)
{
  dVAR;
  int sig;
  PL_sig_pending = 0;
  for (sig = 1; sig < SIG_SIZE; sig++) {
      if (PL_psig_pend[sig]) {
        PERL_BLOCKSIG_ADD(set, sig);
                                                PERL_BLOCKSIG_ADD(set, sig);
                                                PL_psig_pend[sig] = 0;
                                                PERL_BLOCKSIG_BLOCK(set);
                                                (*PL_sighandlerp)(sig);
                                                PERL_BLOCKSIG_UNBLOCK(set);
        PL_psig_pend[sig] = 0;
        PERL_BLOCKSIG_BLOCK(set);
        (*PL_sighandlerp)(sig);
        PERL_BLOCKSIG_UNBLOCK(set);
     }
  }
}

Signals are per process (unless I'm confused)

If a scheduler stops thread 1, and thread 2 runs the same code at the point
shown, then the intended protection of the blocked signals won't be there.

Nicholas Clark
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.