Skip to content

Commit

Permalink
Merge pull request #2594 from DataDog/ivoanjo/fix-flaky-stack-in-nati…
Browse files Browse the repository at this point in the history
…ve-code-detection

Fix profiler sometimes not adding the "In native code" placeholder
  • Loading branch information
ivoanjo committed Feb 3, 2023
2 parents bbdb316 + a1e2ead commit ab0e812
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,17 +422,17 @@ int ddtrace_rb_profile_frames(VALUE thread, int start, int limit, VALUE *buff, i
const rb_control_frame_t *cfp = ec->cfp, *end_cfp = RUBY_VM_END_CONTROL_FRAME(ec);
const rb_callable_method_entry_t *cme;

// This should not happen for ddtrace (it can only happen when a thread is still being created), but I've imported
// it from https://github.com/ruby/ruby/pull/7116 in a "just in case" kind of mindset.
if (cfp == NULL) return 0;

// Avoid sampling dead threads
if (th->status == THREAD_KILLED) return 0;

// `vm_backtrace.c` includes this check in several methods. This happens on newly-created threads, and may
// also (not entirely sure) happen on dead threads
if (end_cfp == NULL) return PLACEHOLDER_STACK_IN_NATIVE_CODE;

// This should not happen for ddtrace (it can only happen when a thread is still being created), but I've imported
// it from https://github.com/ruby/ruby/pull/7116 in a "just in case" kind of mindset.
if (cfp == NULL) return 0;

// Fix: Skip dummy frame that shows up in main thread.
//
// According to a comment in `backtrace_each` (`vm_backtrace.c`), there's two dummy frames that we should ignore
Expand Down

0 comments on commit ab0e812

Please sign in to comment.