Bug #506

ObjectSpace.each_object Segmentation fault

Added by Yusuke Endoh over 6 years ago. Updated about 4 years ago.

[ruby-dev:36009]
Status:Closed
Priority:Low
Assignee:Yusuke Endoh
ruby -v: Backport:

Description

=begin
遠藤です。

2008/08/26 23:37 fujidig fuji.rosen@gmail.com:

Ruby 1.9.0-4 の irb で ObjectSpace.each_object(String){|s| s.dup } を
実行すると SEGV します。

$ irb-1.9.0-4
irb(main):001:0> ObjectSpace.each_object(String){|s| s.dup }
(irb):1: [BUG] Segmentation fault
ruby 1.9.0 (2008-08-26 revision 18849) i686-linux

ご報告ありがとうございます。
おそらく以下のパッチで直ると思います。

Index: string.c
===================================================================
--- string.c (revision 18880)
+++ string.c (working copy)
@@ -669,10 +669,9 @@
else {
RSTRING(str)->as.heap.aux.capa = RSTRING(str2)->as.heap.aux.capa;
}
- RSTRING(str2)->as.heap.ptr = 0; /* abandon str2 /
- RSTRING(str2)->as.heap.len = 0;
- RSTRING(str2)->as.heap.aux.capa = 0;
- STR_UNSET_NOCAPA(str2);
+ STR_SET_EMBED(str2); /
abandon str2 */
+ RSTRING_PTR(str2)[0] = 0;
+ STR_SET_EMBED_LEN(str2, 0);
rb_enc_associate(str, enc);
ENC_CODERANGE_SET(str, cr);
}

--
Yusuke ENDOH mame@tsg.ne.jp
=end

History

#1 Updated by Koichi Sasada over 6 years ago

  • Assignee set to Yusuke Endoh

=begin

=end

#2 Updated by Yukihiro Matsumoto over 6 years ago

  • Status changed from Open to Closed

=begin

=end

Also available in: Atom PDF