From: MenTaLguY Date: 2008-03-25T01:07:37+09:00 Subject: Re: Thread#raise, Thread#kill, and timeout.rb are unsafe On Mon, 24 Mar 2008 22:17:34 +0900, Daniel DeLorme wrote: > I think the specific problem mentionned was that asynchronous exceptions > can abort the cleanup within an ensure section. So what about a simple > solution to that specific problem, like: if an asynchronous exception is > raised inside an ensure section, the exception is queued and raised at > the end of the ensure section. Is that too naive? Maybe slightly. I don't think it would necessarily be an issue for the current implementation of 1.9, but you do also need to do the registration/unregistration of ensure and catch clauses in an uninterruptible fashion. Basically you need to have the equivalent of this: Thread.uninterruptable do begin Thread.interruptable do # ... end rescue # ... ensure # ... end end (in cases where the thread is currently interruptable) See also section 4.2 of "Asynchronous Exceptions in Haskell": http://citeseer.ist.psu.edu/415348.html -mental