Project

General

Profile

Actions

Bug #842

closed

endless loop of ObjectSpace.each_object

Added by authorNari (Narihiro Nakamura) about 16 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
ruby -v:
Backport:
[ruby-dev:37338]

Description

=begin
nariです.

以下の様にすると無限ループに入ります.

$ ./miniruby -v
ruby 1.9.1 (2008-12-10 revision 20602) [i686-linux]
$ ./miniruby -e "GC.disable; ObjectSpace.each_object{ String.new('a') }"

これがバグなのかどうか分かりませんでした.
GC.disableな状態での動作ですので当然といえば当然なのですが..
修正するパッチを添付いたしますので,ご検討程よろしくお願いします.

Index: gc.c

--- gc.c (revision 20602)
+++ gc.c (working copy)
@@ -2089,7 +2089,9 @@
RVALUE *membase = 0;
RVALUE *p, *pend;
volatile VALUE v;

  • int old_dont_gc = dont_gc;

  • if (old_dont_gc) dont_gc = Qfalse;
    i = 0;
    while (i < heaps_used) {
    while (0 < i && (uintptr_t)membase < (uintptr_t)heaps[i-1].membase)
    @@ -2123,6 +2125,7 @@
    }
    }

  • dont_gc = old_dont_gc;
    return SIZET2NUM(n);
    }
    =end

Actions

Also available in: Atom PDF

Like0
Like0Like0