Issue #5130 has been updated by Jeremy Evans.

File thread.c.diff added

Looking at the thread debug log I uploaded earlier, I guessed that this problem might be caused because a thread was starting after rb_thread_terminate_all was called.  rb_thread_terminate_all sets vm->inhibit_thread_creation = 1, which prohibits new threads from being created.  However, it doesn't prevent created-but-not-yet-started threads from starting in thread_start_func_2.  My theory is that thread_start_func_2 should return without starting a thread if vm->inhibit_thread_creation = 1.

The attached patch is a crude form of what I think should happen.  It fixes the Thread.new{Thread.pass} case and the related bootstrap test. It currently passes all make check tests except for one.  The one test failure is:

   46) Error:
  test_signal_requiring(TestSignal):
  EOFError: end of file reached
      /usr/obj/ports/ruby-1.9.3-preview1/ruby-1.9.3-preview1/test/ruby/test_signal.rb:218:in `load'
      /usr/obj/ports/ruby-1.9.3-preview1/ruby-1.9.3-preview1/test/ruby/test_signal.rb:218:in `block in test_signal_requiring'
      /usr/obj/ports/ruby-1.9.3-preview1/ruby-1.9.3-preview1/test/ruby/test_signal.rb:204:in `popen'
      /usr/obj/ports/ruby-1.9.3-preview1/ruby-1.9.3-preview1/test/ruby/test_signal.rb:204:in `test_signal_requiring'

The current patch is probably missing something small in terms of thread cleanup, but as I'm not familiar with the thread code, I'm not sure what that might be.
----------------------------------------
Bug #5130: Thread.pass sticks on OpenBSD
http://redmine.ruby-lang.org/issues/5130

Author: Yui NARUSE
Status: Feedback
Priority: Normal
Assignee: Motohiro KOSAKI
Category: core
Target version: 
ruby -v: -


=begin
On OpenBSD 4.9, following script will stick.

 ./miniruby -ve'Thread.new{Thread.pass}'
=end



-- 
http://redmine.ruby-lang.org