Skip to content

Try to prevent dangling tracked_streams#3689

Open
cataphract wants to merge 1 commit intomasterfrom
glopes/exec-crash
Open

Try to prevent dangling tracked_streams#3689
cataphract wants to merge 1 commit intomasterfrom
glopes/exec-crash

Conversation

@cataphract
Copy link
Contributor

@cataphract cataphract commented Mar 4, 2026

We sometimes find corrupt tracked_streams pointers:

Crash stacktrace (abbreviated):

  zend_hash_str_find               ← SIGSEGV here
  dd_php_stdiop_close_wrapper      ← exec_integration.c:89
  _php_stream_free
  zend_file_handle_dtor
  compile_filename
  dd_execute_php_file              ← autoload triggered by end hook
  zai_sandbox_call / dd_uhook_end  ← post-hook for Slim\App::__construct
  execute_ex / php_execute_script

While the reason why this happens is not entirely clear, it's possible that the previous RSHUTDOWN was not completely executed. This can happen if there are bailouts during RSHUTDOWN.

Fix: wrap the rshutdown tracked_streams iteration in zend_try/zend_catch so any bailout sets tracked_streams = NULL rather than leaving it dangling. Also guard rinit against a non-NULL tracked_streams at request startup.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@cataphract cataphract requested a review from a team as a code owner March 4, 2026 15:58
We sometimes find corrupt tracked_streams pointers:

Crash stacktrace (abbreviated):
  zend_hash_str_find               ← SIGSEGV here
  dd_php_stdiop_close_wrapper      ← exec_integration.c:89
  _php_stream_free
  zend_file_handle_dtor
  compile_filename
  dd_execute_php_file              ← autoload triggered by end hook
  zai_sandbox_call / dd_uhook_end  ← post-hook for Slim\App::__construct
  execute_ex / php_execute_script

While the reason why this happens is not entirely clear, it's possible
that the previous RSHUTDOWN was not completely executed. This can happen
if there are bailouts during RSHUTDOWN.

Fix: wrap the rshutdown tracked_streams iteration in zend_try/zend_catch
so any bailout sets tracked_streams = NULL rather than leaving it dangling.
Also guard rinit against a non-NULL tracked_streams at request startup.
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Mar 4, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1028 Tests failed

testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest (Datadog) (Fix with Cursor)
Risky Test
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:97
testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69a85c27000000001e62d363e7b22fe3
tid: 69a85c2700000000
hexProcessTraceId: 1e62d363e7b22fe3
hexProcessSpanId: 63f94209d214edcb
processTraceId: 2189544794897919971
processSpanId: 7203861688902544843

phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:106
testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69a85c40000000000565a83e00f294a4
tid: 69a85c4000000000
hexProcessTraceId: 0565a83e00f294a4
hexProcessSpanId: d01c83ad8f2e942c
processTraceId: 388901927094752420
processSpanId: 14996005640691684396

phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:106
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5682c31 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.08%. Comparing base (988edd2) to head (5682c31).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3689      +/-   ##
==========================================
- Coverage   62.18%   62.08%   -0.10%     
==========================================
  Files         141      141              
  Lines       13352    13352              
  Branches     1746     1746              
==========================================
- Hits         8303     8290      -13     
- Misses       4259     4269      +10     
- Partials      790      793       +3     

see 3 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 988edd2...5682c31. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pr-commenter
Copy link

pr-commenter bot commented Mar 4, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-03-04 17:32:02

Comparing candidate commit 5682c31 in PR branch glopes/exec-crash with baseline commit 988edd2 in branch master.

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

scenario:BM_TeaSapiSpindown

  • 🟥 execution_time [+10.464µs; +25.937µs] or [+2.008%; +4.976%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-3.408µs; -2.552µs] or [-3.144%; -2.354%]

scenario:TraceSerializationBench/benchSerializeTrace-opcache

  • 🟩 execution_time [-17.179µs; -8.221µs] or [-4.909%; -2.349%]

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.

2 participants