rb_gc_mark(): unknown data type...non object

J

Jim Cain

I figure I'm getting this because I've got a VALUE that's not a Ruby
object. Has anyone figured out a good way to track down such a bug?
 
J

Jim Cain

Yukihiro said:
Hi,

In message "rb_gc_mark(): unknown data type...non object"

|I figure I'm getting this because I've got a VALUE that's not a Ruby
|object. Has anyone figured out a good way to track down such a bug?

I use gdb. If you're not using your own extension, show us the
backtrace (output from gdb "where" command). We may be able to help
you.

matz.

Thanks; it's my Ruby9i extension. I've wasted two days on this and
haven't found anything definitive. Even when I would explicitly start
the gc, sometimes I would get the error and sometimes not. I began to
suspect that it wasn't a bad VALUE but rather a buffer overrun elsewhere
that was corrupting a VALUE.

In the meantime, I was reading some previous posts about rb_obj_alloc
"only working for T_OBJECT classes" in 1.6.x. Just what exactly are
T_OBJECT classes? Non-builtin classes? I wasn't sure just what was meant
by that, and I do use rb_obj_alloc in a few cases, so out of curiosity I
built my extension on 1.8, and now I don't get the gc "unknown data
type" error. At least not yet. Maybe just a coincidence. We'll see.
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: rb_gc_mark(): unknown data type...non object"

|In the meantime, I was reading some previous posts about rb_obj_alloc
|"only working for T_OBJECT classes" in 1.6.x. Just what exactly are
|T_OBJECT classes? Non-builtin classes? I wasn't sure just what was meant
|by that, and I do use rb_obj_alloc in a few cases, so out of curiosity I
|built my extension on 1.8, and now I don't get the gc "unknown data
|type" error. At least not yet. Maybe just a coincidence. We'll see.

Each object has its "type". "type" is not a class. It describes the
structure that object has. For example an object with T_OBJECT type
is implemented by "struct RObject". In 1.6.8, classes does not have
information about the type of its instances, so that rb_obj_alloc()
produces T_OBJECT object, no matter what type it should be. In 1.8.0
each type knows its instance type, so that rb_obj_alloc() work fine
with all classes. But you have to define allocation function using
new rb_define_alloc_func() API.


matz.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top