Skip to content

Add ThreadSanitizer CI - #390

Merged
realFlowControl merged 10 commits into
developfrom
florian/harden-ci
Jul 24, 2026
Merged

Add ThreadSanitizer CI#390
realFlowControl merged 10 commits into
developfrom
florian/harden-ci

Conversation

@realFlowControl

@realFlowControl realFlowControl commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Publish a reusable PHP 8.5.8 base image built with Clang 20 ThreadSanitizer instrumentation from the existing Docker matrix.
  • Build the current parallel.so from each pull request against that image and run a dedicated vanilla TSan job that fails on sanitizer reports.
  • Synchronize monitor state reads and restrict emergency SAPI output mutex recovery to the thread that owns the mutex.
  • Add a FrankenPHP regression test for client disconnects during SAPI output.
  • Pin formatting CI to Clang Format 20 so local and upstream formatting agree.\n- Keep the existing GCC-based builds unchanged.

PHP version scope

TSan intentionally runs only on PHP 8.5. PHP 8.4 and older load extensions with RTLD_DEEPBIND, which is incompatible with the sanitizer runtime. PHP 8.5 stopped using RTLD_DEEPBIND for the CLI when dlmopen() is available, allowing TSan to instrument PHP and parallel.so without carrying a patched PHP build.

Verification

  • Published ghcr.io/krakjoe/php-tsan-8.5:8.5.8 and confirmed the image starts successfully under TSan.
  • Passed all 147 release tests on PHP 8.5.8.
  • Passed all 147 local TSan tests without diagnostics.
  • Reproduced the original FrankenPHP deadlock by removing bailout recovery, then confirmed the ownership-aware recovery remains responsive after eight aborted requests.

Addressed findings

php_parallel_monitor_check() previously read php_parallel_monitor_t::state without synchronization while writers held the monitor mutex. The state is now consistently protected by the recursive monitor mutex instead of relying on volatile.

The SAPI bailout recovery previously unlocked php_parallel_output_mutex after every unclean shutdown, including cancellation bailouts where the current thread did not own the mutex. Thread-local ownership now limits recovery to bailouts that interrupted the SAPI writer while preserving the FrankenPHP client-disconnect behavior from #313.

@realFlowControl
realFlowControl marked this pull request as ready for review July 22, 2026 16:19
@realFlowControl
realFlowControl merged commit 6447fd2 into develop Jul 24, 2026
117 of 143 checks passed
@realFlowControl
realFlowControl deleted the florian/harden-ci branch July 24, 2026 05:50
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