On 2017/05/08 8:08, Eric Wong wrote:
> Back to your original question.  THREAD_RUNNABLE is possible
> if somebody uses Thread#run:
> 
>     require 'thread'
>     m = Mutex.new
>     th = Thread.new do
>       sleep 0.1 # wait for main thread to get lock
>       m.synchronize do
> 	sleep
>       end
>     end
> 
>     m.synchronize do
>       sleep 0.2 # wait for th to block on m.synchronize
>       th.run
>     end

I also confirm that this code set `THREAD_RUNNABLE`. However, `th` waits
locking forever, current `Thread#run` should be bug. mmmm. But not so
serious because it is only small period (maybe as you know). We should
modify later.

> I am not sure about other statuses.  Maybe exit/GC can trigger
> THREAD_KILLED, the mutex_free->rb_mutex_unlock_th call chain
> looks like it might due to GC ordering.  Anyways, I will add
> comments here when I commit.

I think adding rb_bug() guard is good to know the flow of such situation.

-- 
// SASADA Koichi at atdot dot net

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>