From: Eito Katagiri <redmine@...>
Date: 2010-10-02T02:31:05+09:00
Subject: [ruby-core:32667] [Ruby 1.9-Bug#3896][Open] Bus error in ObjectSpace.count_objects_size

Bug #3896: Bus error in ObjectSpace.count_objects_size
http://redmine.ruby-lang.org/issues/show/3896

Author: Eito Katagiri
Status: Open, Priority: Normal
Category: ext, Target version: 1.9.2
ruby -v: ruby 1.9.2p7 (2010-09-29 revision 29373) [i386-darwin9.8.0]

Hello,

ObjectSpace.count_objects_size causes a bus error in ruby-1.9.2.

  > ruby -robjspace -ve "ObjectSpace.count_objects_size"
  ruby 1.9.2p7 (2010-09-29 revision 29373) [i386-darwin9.8.0]
  -e:1: [BUG] Bus Error

The following patch should solve this issue.

diff --git a/gc.c b/gc.c
index 25fcc3d..564d260 100644
--- a/gc.c
+++ b/gc.c
@@ -1145,7 +1145,7 @@ rb_data_typed_object_alloc(VALUE klass, void *datap, const
 size_t
 rb_objspace_data_type_memsize(VALUE obj)
 {
-    if (RTYPEDDATA_P(obj)) {
+    if (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj)->dsize) {
        return RTYPEDDATA_TYPE(obj)->dsize(RTYPEDDATA_DATA(obj));
     }
     else {

The trunk version does not have this issue because it checks the existence of dsize function pointer.


----------------------------------------
http://redmine.ruby-lang.org