Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not check get_DD_TRACE_ENABLED() outside of a request #2631

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

bwoebi
Copy link
Collaborator

@bwoebi bwoebi commented Apr 17, 2024

get_DD_TRACE_ENABLED() must not be accessed outside of requests, given that it accesses a request local array of configs.

DDTRACE_G(active_stack) is supposed to be always properly reset between requests, so we can just put this first and then the calls to get_DD_TRACE_ENABLED() are always correct.

Fixes a crash in datadog_profiling::timeline::timeline_mshutdown doing collect_idle() and ultimately accessing the profiling_context here.

Not sure how to test this; it was reported with the pretty obvious backtrace by an user.

get_DD_TRACE_ENABLED() must not be accessed outside of requests, given that it accesses a request local array of configs.

DDTRACE_G(active_stack) is supposed to be always properly reset between requests, so we can just put this first and then the calls to get_DD_TRACE_ENABLED() are always correct.

Fixes a crash in datadog_profiling::timeline::timeline_mshutdown doing collect_idle() and ultimately accessing the profiling_context here.
@bwoebi bwoebi requested a review from a team as a code owner April 17, 2024 17:02
@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2024

Codecov Report

Merging #2631 (e6caca9) into master (8180fdb) will decrease coverage by 2.18%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2631      +/-   ##
============================================
- Coverage     78.67%   76.49%   -2.18%     
  Complexity     2198     2198              
============================================
  Files           199      130      -69     
  Lines         21955    13095    -8860     
  Branches          0      986     +986     
============================================
- Hits          17273    10017    -7256     
+ Misses         4682     2552    -2130     
- Partials          0      526     +526     
Flag Coverage Δ
appsec-extension 69.00% <ø> (?)
tracer-extension ?
tracer-php 79.79% <ø> (+0.90%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 132 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8180fdb...e6caca9. Read the comment docs.

@pr-commenter
Copy link

pr-commenter bot commented Apr 17, 2024

Benchmarks

Benchmark execution time: 2024-04-17 17:28:04

Comparing candidate commit e6caca9 in PR branch bob/fix-profiler-mshutdown-crash with baseline commit 8180fdb in branch master.

Found 1 performance improvements and 1 performance regressions! Performance is the same for 176 metrics, 0 unstable metrics.

scenario:ContextPropagationBench/benchInject64Bit

  • 🟩 execution_time [-461.407ns; -178.593ns] or [-6.298%; -2.438%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟥 execution_time [+4.310µs; +6.990µs] or [+2.382%; +3.863%]

Copy link
Collaborator

@morrisonlevi morrisonlevi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR. We should definitely write down some of this knowledge on conditional checking order in a code comment so it is not forgotten.

Copy link
Collaborator

@morrisonlevi morrisonlevi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make any sense to fetch DDTRACE_G(active_stack) && DDTRACE_G(active_stack)->root_span from mshutdown? I think we may need to avoid any call to this function after post-request shutdown or so.

@bwoebi
Copy link
Collaborator Author

bwoebi commented Apr 17, 2024

These globals are valid until gshutdown actually, so it's fine.

@morrisonlevi morrisonlevi merged commit b8fd0c3 into master Apr 22, 2024
605 of 606 checks passed
@morrisonlevi morrisonlevi deleted the bob/fix-profiler-mshutdown-crash branch April 22, 2024 14:25
@bwoebi bwoebi added this to the 1.0.0 milestone May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants