Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for Ruby 2.0.0 #56

Merged
merged 2 commits into from

2 participants

Christian Neukirchen Aman Gupta
Christian Neukirchen

First try on fixing #55; this has not been tested yet very much, but the arithmetic example works.

Needs review from someone more versed in Ruby internals.

Aman Gupta
Owner

Thanks.

Aman Gupta tmm1 merged commit 73e7b26 into from
Christian Neukirchen

I noticed a lockup related to a memory-heavy Ruby program, but I don't know how to debug it yet.

Aman Gupta
Owner

Unfortunately perftools.rb's design makes it pretty unstable. The profiling signals sometimes come when the VM is inconsistent.

Ruby 2.0 actually makes call stack profiling a lot easier. You can even do it all in ruby with caller_locations. See http://samsaffron.com/archive/2013/03/19/flame-graphs-in-ruby-miniprofiler

You might also be interested in https://github.com/tmm1/rblineprof which is much better tested and more stable on 1.9 and 2.0.

Christian Neukirchen

Concretely, the program hangs with:

rt_sigreturn()                          = 56
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f34ffa599d0) = ? ERESTARTNOINTR (To be restarted)
--- SIGPROF {si_signo=SIGPROF, si_code=SI_KERNEL} ---
rt_sigreturn()                          = 56
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f34ffa599d0) = ? ERESTARTNOINTR (To be restarted)
--- SIGPROF {si_signo=SIGPROF, si_code=SI_KERNEL} ---
rt_sigreturn()                          = 56
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f34ffa599d0) = ? ERESTARTNOINTR (To be restarted)
--- SIGPROF {si_signo=SIGPROF, si_code=SI_KERNEL} ---
rt_sigreturn()                          = 56
#0  0x00007f34ff125c85 in fork () from /usr/lib/libc.so.6
#1  0x00007f34ff4ebe5c in ?? () from /usr/lib/libruby.so.2.0
#2  0x00007f34ff4f080e in ?? () from /usr/lib/libruby.so.2.0
#3  0x00007f34ff4f0f88 in rb_fork_async_signal_safe ()
   from /usr/lib/libruby.so.2.0
#4  0x00007f34ff4a99f8 in ?? () from /usr/lib/libruby.so.2.0

I am mainly interested in the pprof call graphs however...

Christian Neukirchen chneukirchen deleted the branch
Aman Gupta
Owner

Ah, yes. You're hitting #20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 4 deletions.
  1. +18 −4 ext/perftools.c
22 ext/perftools.c
View
@@ -23,6 +23,10 @@ static VALUE Iallocate;
static VALUE I__send__;
static VALUE Isend;
+#ifndef ID_ALLOCATOR
+#define ID_ALLOCATOR Iallocate
+#endif
+
#define SAVE_FRAME() \
if (method && method != I__send__ && method != Isend) { \
if (self && FL_TEST(klass, FL_SINGLETON) && (BUILTIN_TYPE(self) == T_CLASS || BUILTIN_TYPE(self) == T_MODULE)) \
@@ -125,15 +129,25 @@ static VALUE Isend;
#include <vm_core.h>
#include <iseq.h>
-// Fix compile error in ruby 1.9.3
+// Fix compile error in ruby 1.9.3 and 2.0.0
#ifdef RTYPEDDATA_DATA
-#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
+ #if GET_THREAD
+ #define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
+ #define GET_THREAD2 GET_THREAD
+ #else
+ rb_thread_t *ruby_current_thread;
+ rb_thread_t *GET_THREAD2(void)
+ {
+ ruby_current_thread = ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()));
+ return GET_THREAD();
+ }
+ #endif
#endif
int
rb_stack_trace(void** result, int max_depth)
{
- rb_thread_t *th = GET_THREAD();
+ rb_thread_t *th = GET_THREAD2();
rb_control_frame_t *cfp = th->cfp;
rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th);
@@ -190,7 +204,7 @@ static VALUE Isend;
void
rb_dump_stack()
{
- rb_thread_t *th = GET_THREAD();
+ rb_thread_t *th = GET_THREAD2();
rb_control_frame_t *cfp = th->cfp;
rb_control_frame_t *end_cfp = RUBY_VM_END_CONTROL_FRAME(th);
ID func;
Something went wrong with that request. Please try again.