From f5c2e89cd44a27b2391f94cb1b9cad74b9be692d Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 15 Mar 2014 23:06:32 +0000 Subject: [PATCH] gc.c (objspace_xcalloc): fix GC accounting This hopefully works on all platforms with malloc_usable_size. This may also trigger bugs in places which did not expect GC, too; so maybe some existing code will need RB_GC_GUARD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ gc.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4577385cf1..748026dc16 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Mar 16 08:05:06 2014 Eric Wong + + * gc.c (objspace_xcalloc): fix GC accounting + Sun Mar 16 06:33:35 2014 NARUSE, Yui * addr2line.c (fill_lines): return address is just after calling diff --git a/gc.c b/gc.c index 3b373bef07..95e13c692c 100644 --- a/gc.c +++ b/gc.c @@ -6231,6 +6231,8 @@ objspace_xcalloc(rb_objspace_t *objspace, size_t count, size_t elsize) size = objspace_malloc_prepare(objspace, size); TRY_WITH_GC(mem = calloc(1, size)); + size = objspace_malloc_size(objspace, mem, size); + objspace_malloc_increase(objspace, mem, size, 0, MEMOP_TYPE_MALLOC); return objspace_malloc_fixup(objspace, mem, size); }