Bug #1310
closedHEAP_SIZE で不具合?
Description
=begin
はじめまして.
東京大学の相川と申します.
gc.cのHEAP_SIZEの値を変化させてみたところ,
#define HEAP_SIZE 0x20000
とし,
$ make miniruby
とすると,ビルドは通るのですが,minirubyを実行するとSEGVが出ました.
とりあえず報告させていただきます.
$ ./miniruby -v
[BUG] Segmentation fault
ruby 1.9.2dev (2009-03-22) [i686-linux]
-- control frame ----------
c:0001 p:---- s:0002 b:0002 l:000001 d:000001 TOP
-- C level backtrace information -------------------------------------------
0x819a455 ./miniruby(rb_vm_bugreport+0xb5) [0x819a455]
0x808d9bb ./miniruby [0x808d9bb]
0x808da48 ./miniruby(rb_bug+0x28) [0x808da48]
0x8131eb5 ./miniruby [0x8131eb5]
0xb80a0410 [0xb80a0410]
0x81403cd ./miniruby [0x81403cd]
0x81406a7 ./miniruby(rb_enc_str_new+0x17) [0x81406a7]
0x80dc2ed ./miniruby(rb_intern3+0x16d) [0x80dc2ed]
0x80df74e ./miniruby(rb_intern+0x2e) [0x80df74e]
0x807a0ba ./miniruby(rb_define_module_function+0x4a) [0x807a0ba]
0x80a146c ./miniruby(Init_GC+0x27c) [0x80a146c]
0x80acc15 ./miniruby(rb_call_inits+0x115) [0x80acc15]
0x8092515 ./miniruby(ruby_init+0xa5) [0x8092515]
0x805c6a7 ./miniruby(main+0x47) [0x805c6a7]
0xb7eab685 /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7eab685]
0x805c5c1 ./miniruby [0x805c5c1]
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Aborted
--
東京大学大学院情報理工学系研究科
創造情報学専攻 修士一年
相川 光
=end
Updated by authorNari (Narihiro Nakamura) about 16 years ago
=begin
nariです.
どうやら HEAP_SIZE が大きすぎると,追加する heap_slot 数の計算がおかしくなるようです.
以下の様に修正すると直りました.
宜しければコミットしたいのですがいかがでしょうか.
diff --git a/gc.c b/gc.c
index 835ef5d..8280ec1 100644
--- a/gc.c
+++ b/gc.c
@@ -922,6 +922,9 @@ init_heap(rb_objspace_t *objspace)
add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
-
if (add)
-
add = 1;
-
if ((heaps_used + add) > heaps_length) {
allocate_heaps(objspace, heaps_used + add);
}
@@ -938,6 +941,10 @@ static void
set_heaps_increment(rb_objspace_t *objspace)
{
size_t next_heaps_length = (size_t)(heaps_used * 1.8); -
if (next_heaps_length == heaps_used)
-
next_heaps_length++;
-
heaps_inc = next_heaps_length - heaps_used;
if (next_heaps_length > heaps_length) {
Narihiro Nakmaura
=end
Updated by nobu (Nobuyoshi Nakada) about 16 years ago
=begin
なかだです。
At Sun, 22 Mar 2009 22:48:24 +0900,
Narihiro Nakamura wrote in [ruby-dev:38185]:
@@ -922,6 +922,9 @@ init_heap(rb_objspace_t *objspace)
add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
- if (add)
add = 1;
if (!add) ではなく?
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
=end
Updated by authorNari (Narihiro Nakamura) about 16 years ago
=begin
nari です.
うぅ,失礼しました..
ご指摘ありがとうございます.
diff --git a/gc.c b/gc.c
index 835ef5d..829fa7f 100644
--- a/gc.c
+++ b/gc.c
@@ -922,6 +922,9 @@ init_heap(rb_objspace_t *objspace)
add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
-
if (!add)
-
add = 1;
-
if ((heaps_used + add) > heaps_length) {
allocate_heaps(objspace, heaps_used + add);
}
@@ -938,6 +941,10 @@ static void
set_heaps_increment(rb_objspace_t *objspace)
{
size_t next_heaps_length = (size_t)(heaps_used * 1.8); -
if (next_heaps_length == heaps_used)
-
next_heaps_length++;
-
heaps_inc = next_heaps_length - heaps_used;
if (next_heaps_length > heaps_length) {
2009/03/23 6:52 Nobuyoshi Nakada nobu@ruby-lang.org:
なかだです。
At Sun, 22 Mar 2009 22:48:24 +0900,
Narihiro Nakamura wrote in [ruby-dev:38185]:@@ -922,6 +922,9 @@ init_heap(rb_objspace_t *objspace)
add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
- if (add)
add = 1;
if (!add) ではなく?
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦
--
Narihiro Nakamura
=end
Updated by matz (Yukihiro Matsumoto) about 16 years ago
=begin
まつもと ゆきひろです
In message "Re: [ruby-dev:38187] Re: [Bug #1310] HEAP_SIZE で不具合?"
on Mon, 23 Mar 2009 07:15:37 +0900, Narihiro Nakamura authornari@gmail.com writes:
|ご指摘ありがとうございます.
|
|diff --git a/gc.c b/gc.c
|index 835ef5d..829fa7f 100644
ちゃんと動かして問題が出ないようならコミットしてください。
=end
Updated by authorNari (Narihiro Nakamura) about 16 years ago
- Status changed from Open to Closed
- Assignee set to authorNari (Narihiro Nakamura)
=begin
=end