TYPE(cl) in rb_obj_is_kind_of

rb_obj_is_kind_of e$BCf$Ge(B TYPE(cl) e$B$,e(B T_CLASS e$B$de(B T_ICLASS
e$B$G$Je(B
[email protected]>o$J$N$G$7$g$&$+e(B?

e$B$D$^$j!"0J2<[email protected]$O4V0c$C$F$$$k$G$7$g$&$+e(B?

Index: object.c

— object.c (revision 13472)
+++ object.c (working copy)
@@ -11,6 +11,7 @@
Copyright © 2000 Information-technology Promotion Agency, Japan

**********************************************************************/
+#include <assert.h>

#include “ruby/ruby.h”
#include “ruby/st.h”
@@ -390,6 +391,7 @@
rb_obj_is_kind_of(VALUE obj, VALUE c)
{
VALUE cl = CLASS_OF(obj);

  • assert(TYPE(cl) == T_CLASS || TYPE(cl) == T_ICLASS);

    switch (TYPE©) {
    case T_MODULE:

[email protected]$r$D$1$k$H!"e(Btest/runner.rb
e$B$,0J2<$N$h$&$K<:GT$7$^$9!#e(B

% ./ruby test/runner.rb
ruby: object.c:394: rb_obj_is_kind_of: Assertion `rb_type((VALUE)(cl))
== RUBY_T_CLASS || rb_type((VALUE)(cl)) == RUBY_T_ICLASS’ failed.

e$B0J2<$N$h$&$K$9$l$P!">.$5$J%9%/%j%W%H$G:F8=$5$;$k$3$H$,$G$-$^e(B
e$B$9!#e(B

% ls -l empty.rb z.rb
-rw-r–r-- 1 akr akr 0 Sep 20 23:29 empty.rb
-rw-r–r-- 1 akr akr 81 Sep 20 23:29 z.rb
% cat z.rb
eval(“require ‘empty’”, TOPLEVEL_BINDING)
ObjectSpace.each_object(Class) {|x| }
% ./ruby z.rb
ruby: object.c:394: rb_obj_is_kind_of: Assertion `rb_type((VALUE)(cl))
== RUBY_T_CLASS || rb_type((VALUE)(cl)) == RUBY_T_ICLASS’ failed.

In article [email protected],
Tanaka A. [email protected] writes:

e$B0J2<$N$h$&$K$9$l$P!">.$5$J%9%/%j%W%H$G:F8=$5$;$k$3$H$,$G$-$^e(B
e$B$9!#e(B

e$B$&!"0J2<$G==J,$G$7$?!#e(B

% ./ruby -e ‘eval("", TOPLEVEL_BINDING); ObjectSpace.each_object(Class)
{|x| }’
ruby: object.c:394: rb_obj_is_kind_of: Assertion `rb_type((VALUE)(cl))
== RUBY_T_CLASS || rb_type((VALUE)(cl)) == RUBY_T_ICLASS’ failed.

[email protected]$G$9!#e(B

At Thu, 20 Sep 2007 23:34:33 +0900,
Tanaka A. wrote in [ruby-dev:31804]:

rb_obj_is_kind_of e$BCf$Ge(B TYPE(cl) e$B$,e(B T_CLASS e$B$de(B T_ICLASS e$B$G$Je(B
[email protected]>o$J$N$G$7$g$&$+e(B?

e$B$=$ND>8e$Ne(Bswitche$B$r$_$l$P!"e([email protected]>o$J%1!<%[email protected]$H;W$$$^$9!#e(B

In article [email protected],
Nobuyoshi N. [email protected] writes:

rb_obj_is_kind_of e$BCf$Ge(B TYPE(cl) e$B$,e(B T_CLASS e$B$de(B T_ICLASS e$B$G$Je(B
[email protected]>o$J$N$G$7$g$&$+e(B?

e$B$=$ND>8e$Ne(Bswitche$B$r$_$l$P!"e([email protected]>o$J%1!<%[email protected]$H;W$$$^$9!#e(B

e$B$&$%$`!#e(B

e$B$3$N7o$G$Oe(B T_MODULE e$B$G$b$J$$$h$&$G$9!#e(B

% gdb ruby
GNU gdb 6.3-debian
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for
details.
This GDB was configured as “i386-linux”…Using host libthread_db
library “/lib/tls/libthread_db.so.1”.

(gdb) run -e ‘eval("", TOPLEVEL_BINDING); ObjectSpace.each_object(Class)
{|x| }’
Starting program: /tmp/a/ruby/ruby -e ‘eval("", TOPLEVEL_BINDING);
ObjectSpace.each_object(Class) {|x| }’
[Thread debugging using libthread_db enabled]
[New Thread -1210039200 (LWP 27073)]
[New Thread -1210770512 (LWP 27076)]
ruby: object.c:394: rb_obj_is_kind_of: Assertion `rb_type((VALUE)(cl))
== RUBY_T_CLASS || rb_type((VALUE)(cl)) == RUBY_T_ICLASS’ failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread -1210039200 (LWP 27073)]
0xb7e2d83b in raise () from /lib/tls/libc.so.6
(gdb) bt
#0 0xb7e2d83b in raise () from /lib/tls/libc.so.6
#1 0xb7e2efa2 in abort () from /lib/tls/libc.so.6
#2 0xb7e272df in __assert_fail () from /lib/tls/libc.so.6
#3 0x0807768d in rb_obj_is_kind_of (obj=0, c=3084396900) at ruby.h:897
#4 0x0806327b in os_obj_of (of=3084396900) at gc.c:1744
#5 0x0806330c in os_each_obj (argc=0, argv=0x0) at gc.c:1799
#6 0x080d96da in call_cfunc (func=0x80632c0 <os_each_obj>,
recv=3084273360, len=6, argc=27073, argv=0xb7d83020)
at insnhelper.ci:276
#7 0x080dac15 in vm_call_cfunc (th=0x815d160, reg_cfp=0xb7e02f60,
num=1, id=8080, recv=3084273360, klass=3084273260,
mn=0xb7d64658, blockptr=0x0) at insnhelper.ci:365
#8 0x080d9e06 in vm_call_method (th=0x815d160, cfp=0xb7e02f60, num=1,
blockptr=0xb7e02f74, flag=0, id=8080, mn=0x815d160,
recv=3084273360, klass=3084273260) at insnhelper.ci:490
#9 0x080d5360 in vm_eval (th=0x815d160, initial=0) at insns.def:1073
#10 0x080d84b0 in vm_eval_body (th=0x815d160) at vm.c:1162
#11 0x080d887a in rb_iseq_eval (iseqval=3084259860) at vm.c:1371
#12 0x0805a589 in ruby_exec_node (n=0xb7d61250, file=0x8197139 “-e”) at
eval.c:231
#13 0x0805a5ef in ruby_run_node (n=0xb7d61250) at eval.c:256
#14 0x08057757 in main (argc=0, argv=0x0, envp=0xbfe6f0d4) at main.c:46
(gdb) up
#1 0xb7e2efa2 in abort () from /lib/tls/libc.so.6
(gdb)
#2 0xb7e272df in __assert_fail () from /lib/tls/libc.so.6
(gdb)
#3 0x0807768d in rb_obj_is_kind_of (obj=0, c=3084396900) at ruby.h:897
897 if (obj == Qfalse) return rb_cFalseClass;
(gdb)
#4 0x0806327b in os_obj_of (of=3084396900) at gc.c:1744
1744 if (rb_obj_is_kind_of((VALUE)p, of)) {
(gdb) rp p
T_VALUES: $1 = (struct RValues *) 0xb7d60fbc
(gdb) p *$1
$2 = {basic = {flags = 26, klass = 3084262000}, v1 = 4, v2 = 4, v3 = 4}
(gdb) rp 3084262000
T_NODE(NODE_BLOCK): $3 = {flags = 1055, nd_file = 0x0, u1 = {node =
0xb7d829b4, id = 3084396980, value = 3084396980,
cfunc = 0xb7d829b4, tbl = 0xb7d829b4}, u2 = {node = 0x2, id = 2,
argc = 2, value = 2}, u3 = {node = 0x0, id = 0,
state = 0, entry = 0x0, cnt = 0, value = 0}}
(gdb)

e$B$H$$$&$h$&$K!"e(Brb_obj_is_kind_of e$B$KEO$7$F$$$k$N$Oe(B T_VALUES
e$B$G!"e(B
e$B$=$Ne(B klass e$B$Oe(B T_NODE e$B$K$J$C$F$$$^$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs