[Ruby 1.9-Bug#4131][Assigned] can't set length of shared string error in IO#read

Bug #4131: can’t set length of shared string error in IO#read
http://redmine.ruby-lang.org/issues/show/4131

起票者: Masaya T.
ステータス: Assigned, 優先度: Low
担当者: Masaya T., カテゴリ: core
ruby -v: ruby 1.9.3dev (2010-12-07 trunk 30119) [i386-mswin32_90]

IO#readにおいて、
lengthがnilでbufferにsharedなStringを指定したときに以下のようにエラーになります。

ruby -ve “a=‘abcdefghijkl’;b=a[1,3];STDIN.read(nil,a)”
ruby 1.9.3dev (2010-12-07 trunk 30119) [i386-mswin32_90]
-e:1:in read': can't set length of shared string (RuntimeError) from -e:1:in

patchを貼り付けますが、この後、他のbugfixのためにリファクタリング予定です。
Index: io.c

— io.c (リビジョン 30119)
+++ io.c (作業コピー)
@@ -2212,7 +2212,10 @@
rb_scan_args(argc, argv, “02”, &length, &str);

 if (NIL_P(length)) {
  •   if (!NIL_P(str)) StringValue(str);
    
  •   if (!NIL_P(str)){
    
  •       StringValue(str);
    
  •       rb_str_modify(str);
    
  •   }
      GetOpenFile(io, fptr);
      rb_io_check_char_readable(fptr);
      return read_all(fptr, remain_size(fptr), str);
    

チケット #4131 が更新されました。 (by Masaya T.)

ステータス AssignedからClosedに変更
進捗 % 0から100に変更

This issue was solved with changeset r30122.
Masaya, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.