From 4157bd27b36b8d8284017781bd00ee988e63ffa4 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 10 Jun 2024 13:01:21 +0200 Subject: [PATCH] Ensure DDTRACE_G(active_stack) is always NULL when the root span is being pushed I have zero idea _how_ this happened, given that I'm unable to reproduce it, but a core dump indicated that the memory it pointed to was from the previous request. While this is not a very proper fix (as this should not be possible in the first place), it mitigates the effects. Signed-off-by: Bob Weinand --- ext/ddtrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index c6d1bf3f12..254c2a3804 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -1302,6 +1302,7 @@ static PHP_RINIT_FUNCTION(ddtrace) { if (!ddtrace_disable) { // With internal functions also being hookable, they must not be hooked before the CG(map_ptr_base) is zeroed zai_hook_activate(); + DDTRACE_G(active_stack) = NULL; // This should not be necessary, but somehow sometimes it may be a leftover from a previous request. DDTRACE_G(active_stack) = ddtrace_init_root_span_stack(); #if PHP_VERSION_ID < 80000 ddtrace_autoload_rinit();