develooper Front page | perl.perl5.porters | Postings from June 2010

Re: [perl #74868] Safe signals changes causing hangs with threads

Thread Previous
From:
Dave Mitchell
Date:
June 4, 2010 09:15
Subject:
Re: [perl #74868] Safe signals changes causing hangs with threads
Message ID:
20100604161438.GA13715@iabyn.com
On Mon, May 03, 2010 at 06:48:03AM -0700, Jerry D. Hedden wrote:
> Commit f410a2119920dd04690025a349e79575cfb9c972 to blead
> changed where PERL_ASYNC_CHECK() is called for safe signals.
> One of the changes added PERL_ASYNC_CHECK() to the end of
> Perl_leave_scope().  However, this causes deadlocks to occur
> if a signal handler in a threaded application tries to
> lock() a shared variable "at the same time" that another
> thread tries to manipulate another shared variable.
> 
> This was noticed because the Thread::Suspend module's test
> suite was frequently hanging.  My original posting and Dave
> Mitchell's reply can be found here:
> 
> http://www.nntp.perl.org/group/perl.perl5.porters/2010/04/msg159322.html
> 
> Attached is a patch to fix this problem by removing the
> PERL_ASYNC_CHECK() call from Perl_leave_scope().  I have
> tested this patch and have been using it for several days
> and have not found any problems with it.

I've gone with Nicholas's suggestion and added a veto on signal handler
calling while we hold the global lock.

This is done with commits

92f022bbf8c129c6f2379a382f1eaaa5c7bd9f3f
    adds PL_signalhook to core

65c7421c80585e0d12a20773935dc01f4ffa3e42
    makes threads::shared use PL_signalhook

-- 
Spock (or Data) is fired from his high-ranking position for not being able
to understand the most basic nuances of about one in three sentences that
anyone says to him.
    -- Things That Never Happen in "Star Trek" #19

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About