Skip to content

fix(ci): windows test_c 8.5 — stop suite-abort on live-debugger hang + capture stack - #4066

Draft
Leiyks wants to merge 1 commit into
masterfrom
leiyks/fix-ci-windows-test-c-livedebugger-hang
Draft

fix(ci): windows test_c 8.5 — stop suite-abort on live-debugger hang + capture stack#4066
Leiyks wants to merge 1 commit into
masterfrom
leiyks/fix-ci-windows-test-c-livedebugger-hang

Conversation

@Leiyks

@Leiyks Leiyks commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What

  • Fix windows test_c: [8.5] aborting the whole suite (~229/692 tests run) when a tests/ext/live-debugger/ test hangs in teardown.
  • Add an in-extension, CI-only teardown hang watchdog (Windows) that dumps the wedged main-thread stack and exits the child before run-tests.php's 60s timeout.
  • Add a tolerant CI-time patch to the phpize-provided run-tests.php as independent insurance.

Why

Root cause of the secondary, suite-killing failure (fully diagnosed):

  1. A live-debugger test hangs ≥60s in extension/sidecar teardown (the ultimate cause of the hang itself is not yet pinned — it needs a stack from a live Windows run, which this PR captures).
  2. run-tests.php times it out and calls proc_terminate($proc, 9). On Windows this does not reliably kill the process tree, so the wedged php.exe keeps an OS lock on <test>.php.
  3. goto retry re-runs the test → save_text()file_put_contents() on the locked file returns falseerror()exit(1), fatally killing the run mid-suite.

How

1. Teardown hang watchdog (ext/hang_watchdog_windows.{c,h}, wired into PHP_RSHUTDOWN_FUNCTION(datadog) in ext/datadog.c):

  • Armed at the start of request teardown, but only when _DD_TEST_HANG_WATCHDOG_SEC is set (set to 40 in the CI job, unset everywhere else → no-op in production). Arm-once per process.
  • If teardown doesn't finish in time, a watchdog thread suspends the main thread, walks + symbolizes its stack via dbghelp/StackWalk64 (dbghelp/psapi already linked in config.w32), writes it straight to the OS stdout handle (bypassing the CRT stdio lock the suspended thread may hold), then TerminateProcess(self, 3).
  • Exiting before the 60s timeout means run-tests.php reports a plain FAILED (with the stack in the diff) instead of hitting the timeout→retry→exit(1) cascade. Banner wording deliberately avoids run-tests' flaky-retry keywords.
  • Windows-only: the .c is added to config.w32 only; the header is a static inline no-op on non-Windows, so datadog.c is unchanged elsewhere.

2. run-tests.php hardening (.gitlab/patch-run-tests-windows.php, invoked from the windows test_c job in .gitlab/generate-tracer.php):

  • (a) taskkill /T /F the timed-out process tree before proc_terminate so the file lock is released before the retry.
  • (b) Retry the save_text() write with a short backoff instead of aborting.
  • Anchors are line-ending-aware and tolerant across the PHP 7.2–8.5 matrix: a missing anchor is a no-op (no regression), only an ambiguous (>1) match is fatal.

Testing

  • Local: patch-run-tests-windows.php verified against real run-tests.php for all 9 matrix versions (LF + CRLF) — applies on 8.2–8.5, tree-kill on 7.4+, byte-identical no-op on 7.2/7.3; all patched outputs php -l clean.
  • Local: modified ext/datadog.c compiles clean (-fsyntax-only, real PHP debug headers, -DDDTRACE); non-Windows header no-op compiles; generate-tracer.php lints and renders the job correctly.
  • CI: windows test_c: [8.5] — the primary verification. This run should (a) no longer abort the suite and (b) emit the hung thread's stack in the job log.

Notes

  • The watchdog cannot be exercised on Linux; the Windows hang path is only verifiable on the next windows test_c CI run.
  • Follow-up (next CI run): read the captured main-thread stack from the windows test_c: [8.5] log, then root-cause the ≥60s teardown hang itself. If the watchdog does NOT fire (still a silent 60s timeout), the hang is before RSHUTDOWN and the arm point should move earlier.

… capture live-debugger hang stack [windows test_c]
@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Jul 27, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

⚠️ Warnings

🚦 10 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | ASAN test_c with multiple observers: [8.3]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-php | ASAN test_c: [8.5, arm64]   View in Datadog   GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [7.1]   View in Datadog   GitLab

View all 10 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.65% (-0.02%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4d242d5 | Docs | Datadog PR Page | Give us feedback!

@pr-commenter

pr-commenter Bot commented Jul 27, 2026

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-07-27 14:24:05

Comparing candidate commit 4d242d5 in PR branch leiyks/fix-ci-windows-test-c-livedebugger-hang with baseline commit b2d669e in branch master.

Found 0 performance improvements and 4 performance regressions! Performance is the same for 190 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-opcache

  • 🟥 execution_time [+298.730ns; +627.270ns] or [+2.241%; +4.705%]

scenario:EmptyFileBench/benchEmptyFileDdprof

  • 🟥 execution_time [+80.907µs; +278.933µs] or [+2.263%; +7.801%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟥 execution_time [+3.542µs; +5.118µs] or [+3.391%; +4.899%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟥 execution_time [+2.283µs; +4.177µs] or [+2.130%; +3.897%]

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.

1 participant