Project

General

Profile

Actions

Bug #4272

closed

rb_enc_str_new() causes segmentfault when using threads in parallel

Bug #4272: rb_enc_str_new() causes segmentfault when using threads in parallel

Added by ibc (Iñaki Baz Castillo) about 15 years ago. Updated almost 15 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
1.9.2-p136
Backport:
[ruby-core:34399]

Description

=begin
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).
=end


Files

test_encoding.c (1.01 KB) test_encoding.c ibc (Iñaki Baz Castillo), 01/12/2011 11:04 AM
extconf.rb (108 Bytes) extconf.rb ibc (Iñaki Baz Castillo), 01/12/2011 11:04 AM
test_bug.rb (503 Bytes) test_bug.rb ibc (Iñaki Baz Castillo), 01/12/2011 11:04 AM
test_bug.rb (510 Bytes) test_bug.rb ibc (Iñaki Baz Castillo), 01/12/2011 06:38 PM
test_bug2.rb (317 Bytes) test_bug2.rb ibc (Iñaki Baz Castillo), 01/13/2011 01:22 AM
Actions

Also available in: PDF Atom