From: Charles Oliver Nutter Date: 2008-03-22T15:05:53+09:00 Subject: Re: Thread#raise, Thread#kill, and timeout.rb are unsafe MenTaLguY wrote: > On Sat, 15 Mar 2008 01:00:49 +0900, Roger Pack wrote: >> It was the problems with timeout that make me wish we had an >> EnsureCritical (an Ensure that gets Thread.critical=true set to it >> before entering it), so that timeouts can end properly. > > Anything using Thread.critical has its own problems, particularly > when native threads are involved. It can easily result in deadlocks > if the running thread inadvertently tries to use something which another > stopped thread is using (imagine a thread stopped halfway through > releasing a lock that the ensure block needs to acquire, for example > -- something which would have worked fine with normal use of locks, but > becomes a problem once threads can "stop the world"). And to clarify, this problem isn't restricted to native threads...even a green-threaded model could deadlock if one thread goes critical while other threads are holding unrelated locks. - Charlie