Skip to content

Commit

Permalink
Fix crash in profiler when span stack switch causes GC run (#2885)
Browse files Browse the repository at this point in the history
gc_collect_cycles may be intercepted by profiler and when happening precisely within ddtrace_switch_span_stack, the DDTRACE_G(active_span) points to just freed memory.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi authored Oct 9, 2024
1 parent df24834 commit 0430ed8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ext/span.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ void ddtrace_switch_span_stack(ddtrace_span_stack *target_stack) {
}

GC_ADDREF(&target_stack->std);
OBJ_RELEASE(&DDTRACE_G(active_stack)->std);
ddtrace_span_stack *active_stack = DDTRACE_G(active_stack);
DDTRACE_G(active_stack) = target_stack;
OBJ_RELEASE(&active_stack->std);
}

ddtrace_span_data *ddtrace_init_dummy_span(void) {
Expand Down

0 comments on commit 0430ed8

Please sign in to comment.