codemancers / rbkit

A new profiler for Ruby. With a GUI
http://rbkit.c9s.dev/
MIT License
358 stars 11 forks source link

rb_class2name can seg fault #9

Closed gnufied closed 10 years ago

gnufied commented 10 years ago

Currently I think rb_class2name can segfault under certain conditions. I think the case in point is, when it is called from free_obj_i function.

It seems that certain stack frames and data structures are not safe to be used, when free_obj_i hook runs. To that in, builtin ruby object tracer actually stores, class name etc in separate hash table, when object was created, it does not attempt to use rb_class2name during free method calls. I have half implemented that work. We need to ensure that, we do this properly.

emilsoman commented 10 years ago

When I was tinkering with the object graph, I realized that rb_class2name works only if this condition is true, else it segfaults : if (!NIL_P(klass) && BUILTIN_TYPE(v) != T_NONE && BUILTIN_TYPE(v) != T_ZOMBIE && BUILTIN_TYPE(v) != T_ICLASS)

v is the object.

gnufied commented 10 years ago

interesting. May be we can use this as a stop gap measure until, we start storing object details in hash table along with file and line numbers.

gnufied commented 10 years ago

Unfortunately crash is still there. try running a rails app with rbkit and hitting it with "ab" to streess test. The app crashes.

emilsoman commented 10 years ago

Alright, I'll look into this.

emilsoman commented 10 years ago

This issue seems to be gone now. Was this related to #15 ?