Skip to content

Commit

Permalink
Ensure DDTRACE_G(active_stack) is always NULL when the root span is b…
Browse files Browse the repository at this point in the history
…eing 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 <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed Jun 10, 2024
1 parent c5f2dcb commit 4157bd2
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4157bd2

Please sign in to comment.