From 261400e7a9b4e8774a058e9a6f53fc885329c5f8 Mon Sep 17 00:00:00 2001 From: nari Date: Mon, 13 Feb 2012 12:57:16 +0000 Subject: [PATCH] * gc.c (HEAP_OBJ_LIMIT, HEAP_BITMAP_LIMIT): HEAP_OBJ_LIMIT used `sizeof(struct heaps_slot)` while heap is currently allocated with `struct heaps_header`. HEAP_BITMAP_LIMIT were calculated from `HEAP_OBJ_LIMIT/sizeof(uintptr_t)` - one Byte for each object, not one Bit. [Bug #6006] patched by Sokolov Yura. https://github.com/ruby/ruby/pull/92 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ gc.c | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 73a199726e..2f57d1726b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Mon Feb 13 21:52:06 2012 Narihiro Nakamura + + * gc.c (HEAP_OBJ_LIMIT, HEAP_BITMAP_LIMIT): HEAP_OBJ_LIMIT used + `sizeof(struct heaps_slot)` while heap is currently allocated + with `struct heaps_header`. + HEAP_BITMAP_LIMIT were calculated from + `HEAP_OBJ_LIMIT/sizeof(uintptr_t)` - one Byte for each object, + not one Bit. [Bug #6006] + patched by Sokolov Yura. https://github.com/ruby/ruby/pull/92 + Mon Feb 13 18:30:32 2012 Nobuyoshi Nakada * io.c (io_setstrbuf): defer resizing buffer string until data is diff --git a/gc.c b/gc.c index 2c49f96363..4c5a91ccbb 100644 --- a/gc.c +++ b/gc.c @@ -544,9 +544,10 @@ rb_objspace_free(rb_objspace_t *objspace) #define HEAP_ALIGN_MASK (~(~0UL << HEAP_ALIGN_LOG)) #define REQUIRED_SIZE_BY_MALLOC (sizeof(size_t) * 5) #define HEAP_SIZE (HEAP_ALIGN - REQUIRED_SIZE_BY_MALLOC) +#define CEILMOD(i, mod) (((i) + (mod) - 1)/(mod)) -#define HEAP_OBJ_LIMIT (unsigned int)(HEAP_SIZE/sizeof(struct RVALUE) - (sizeof(struct heaps_slot)/sizeof(struct RVALUE)+1)) -#define HEAP_BITMAP_LIMIT (HEAP_OBJ_LIMIT/sizeof(uintptr_t)+1) +#define HEAP_OBJ_LIMIT (unsigned int)((HEAP_SIZE - sizeof(struct heaps_header))/sizeof(struct RVALUE)) +#define HEAP_BITMAP_LIMIT CEILMOD(HEAP_OBJ_LIMIT, sizeof(uintptr_t)*8) #define GET_HEAP_HEADER(x) (HEAP_HEADER(((uintptr_t)x) & ~(HEAP_ALIGN_MASK))) #define GET_HEAP_SLOT(x) (GET_HEAP_HEADER(x)->base)