Hi,

I could not reproduce your problem, but your script allocates
thousands of threads by default.  Each thread consumes at least 1M of
memory, so that allocating thousands of threads could cause memory
starvation, which may be the source of your problem.

							matz.

In message "Re: [ruby-core:34399] [Ruby 1.9-Bug#4272][Open] rb_enc_str_new() causes segmentfault when using threads in parallel"
    on Wed, 12 Jan 2011 11:04:21 +0900, Iaki Baz Castillo <redmine / ruby-lang.org> writes:

|Hi, I attach a custom C extension which shows how rb_enc_str_new() causes segmentfault when running multiple threads. The bug is reproducible in 1.9.2-p0, 1.9.2-p136 and 1.9 today's snapshot (2011-01-12).
|
|In order to test the bug compile the extension and use the included test_bug.rb script passing a long number (iterations) as argument (1000, 10000...).
|
|  ~# ruby extconf.rb && make && ruby test_bug.rb 5000
|
|The provided C extension is very simple and just contains two methods:
|
|  TestEncoding::Tester#test_rb_str_new => returns a string encoded in ASCII-8BIT (generated with "rb_str_new").
|  TestEncoding::Tester#test_rb_enc_str_new => returns a string encoded in UTF-8 (generated with "rb_enc_str_new").
|
|When running threads in parallel with the second method, after some iterations Ruby crashses (as the provided test_bug.rb shows).