From: John Briggs on
Also able to reach the crash with:

700.times{|i|
Thread.new{}
puts i
}

and even with:

700.times{
Thread.new{}
puts "."
}


but not with:

700.times{
Thread.new{}
}


[Note: The script crashes even when 0 < i < 10]
--
Posted via http://www.ruby-forum.com/.

From: Luis Lavena on
On Apr 21, 4:18 pm, John Briggs <aazma...(a)gmail.com> wrote:
> Luis Lavena wrote:
> > As for the original reporter of the issue:
>
> > You're trying to "print" to STDOUT from different threads, which will
> > produce a race conditions and depending other operations you're
> > performing, highly likely will crash.
>
> > Add to that, you're trying to spawn 700 threads, which spawned quickly
> > will generate overhead and highly likely you're exhausting resources
> > in the process (since you don't get a backtrace of your test script)
>
> > But more concrete, exhausting of resources could be associated with
> > available descriptors that Ruby 1.9 has been compiled for.
>
> Actually I get the crash for both 700 threads and 10 threads. Initially
> I wrote the script with 25 threads and the 700 one remained from the
> last tests.
> Also I tried to put delays between thread spawning but couldn't get rid
> of the crash.
> And one more thing: I tried to run this script on JRuby and it works
> without problems even with 700 threads and without any delays, so the
> problem doesn't seem to be in threads amount or resources exhausting.

Invalid handle might be associated with handles allocated by Ruby to
keep track of the native threads.

JRuby implements native threads but in a different way than Ruby 1.9

It will be worth waiting for answers from Ruby-Core regarding your bug
report for Ruby 1.9 project.

--
Luis Lavena