Skip to content

Add PHPT reproducer for aborted generator stale caller frames - #4272

Open
morrisonlevi wants to merge 3 commits into
masterfrom
levi/repro-generator-dtor-stale-stack
Open

morrisonlevi wants to merge 3 commits into
masterfrom
levi/repro-generator-dtor-stale-stack

Conversation

@morrisonlevi

Copy link
Copy Markdown
Collaborator

Description

@bwoebi, here is a reproducer for the issue I found while investigating customer crashes. The profiler is not at fault, I think any product which walks the stack would trigger it.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@github-actions github-actions Bot added profiling Relates to the Continuous Profiler tracing labels Oct 3, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 2 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | installer tests — 🔄 Retry may pass, looks flaky

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | publish docker image for system tests

View more details · View in GitLab

⚠️ Warnings

❄️ 1 New flaky test detected

tmp/build_extension/tests/ext/sandbox/install_hook/backtrace_after_sandbox_bailout.phpt (End hooks can collect a backtrace after a sandboxed fatal error) from PHP.tmp.build_extension.tests.ext.sandbox.install_hook
end hook
002+ =================================================================
003+ ==3855==ERROR: AddressSanitizer: stack-use-after-return on address 0xdf298ce21858 at pc 0xba7fb7912b6c bp 0xffffe0794830 sp 0xffffe0794828
004+ READ of size 8 at 0xdf298ce21858 thread T0
002- application continues
003- application end
004- done
005+     #0 0xba7fb7912b68 in zend_observer_is_skipped_frame /usr/local/src/php/Zend/zend_observer.c:181:38
006+     #1 0xba7fb7912a5c in zend_observer_fcall_end /usr/local/src/php/Zend/zend_observer.c:221:16
007+     #2 0xba7fb7913020 in zend_observer_fcall_end_all /usr/local/src/php/Zend/zend_observer.c:233:4
...

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 68.38% (-0.07%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5c9d39f | Docs | View more details | Give us feedback!

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
@pr-commenter

pr-commenter Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-10-06 12:27:45

Comparing candidate commit 5c9d39f in PR branch levi/repro-generator-dtor-stale-stack with baseline commit a729615 in branch master.

📊 Benchmarking dashboard

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

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:ContextPropagationBench/benchInject64Bit

  • 🟥 execution_time [+61.770ns; +124.230ns] or [+2.835%; +5.701%]

scenario:HookBench/benchHookOverheadTraceMethod-opcache

  • 🟩 execution_time [-8.710µs; -3.627µs] or [-4.843%; -2.017%]

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
@bwoebi
bwoebi marked this pull request as ready for review October 6, 2026 18:03
@bwoebi
bwoebi requested review from a team as code owners October 6, 2026 18:03
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T18:10:29.045530Z 5c9d39f Draft marked ready
🔒 Security Review ✅ Completed 2026-10-06T18:11:25.832378Z 5c9d39f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

}
zai_interceptor_handle_ended_generator(generator, execute_data, retval, frame_memory);

/* PHP's observer chain omits suspended yield-from delegating generators. End the active chain on bailout too. */

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Think it's worth a test for bailouts here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

profiling Relates to the Continuous Profiler tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants