Project

General

Profile

Actions

Bug #506

closed

ObjectSpace.each_object Segmentation fault

Added by mame (Yusuke Endoh) about 16 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
Backport:
[ruby-dev:36009]

Description

=begin
遠藤です。

2008/08/26 23:37 fujidig :

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]
(snip)

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

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
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0