File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ ZEND_EXTERN_MODULE_GLOBALS(ddtrace);
88
99DDTRACE_PUBLIC struct ddtrace_profiling_context ddtrace_get_profiling_context (void ) {
1010 struct ddtrace_profiling_context context = {0 , 0 };
11- if (DDTRACE_G (active_stack ) && DDTRACE_G (active_stack )-> root_span && get_DD_TRACE_ENABLED ()) {
11+ // NOTE: `active_stack->active` may legitimately be NULL during span close (e.g. when closing the last span on a
12+ // stack, `ddtrace_close_top_span_without_stack_swap()` updates it before running additional logic that may still
13+ // allocate, such as JSON encoding during sampling decisions). Allocation profiling can call into this function
14+ // from within those allocations, so treat "no active span" as "no profiling context" instead of dereferencing.
15+ if (DDTRACE_G (active_stack ) && DDTRACE_G (active_stack )-> root_span && DDTRACE_G (active_stack )-> active && get_DD_TRACE_ENABLED ()) {
1216 context .local_root_span_id = DDTRACE_G (active_stack )-> root_span -> span_id ;
1317 context .span_id = SPANDATA (DDTRACE_G (active_stack )-> active )-> span_id ;
1418 }
You can’t perform that action at this time.
0 commit comments