Race conditions on tracing globals in jit-tracing mode in ZTS
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
While testing opcache.jit=tracing with a threading extension and valgrind --tool=drd, a good number of my extension's tests started detecting race conditions in zend_jit_trace_hot_root and some other places.
I'm seeing races in the following places:
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit_trace.c#L7231
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit_trace.c#L7701
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit_trace.c#L7731
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit_trace.c#L8033
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit_trace.c#L8051
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit.c#L5096
https://github.com/php/php-src/blob/PHP-8.3.13/ext/opcache/jit/zend_jit_vm_helpers.c#L899
and a few other places
Vast majority seem to have zend_jit_trace_hot_root() in the stack traces
I have a whole bunch of test outputs from my CI if these are any help. Unfortunately the traces are a bit jumbled up in some cases for whatever reason.
Basically it looks like races may occur if two threads try to perform tracing JIT at the same time.
test-results-8.3.13-valgrind-drd-opcache-jit-tracing.zip
from
https://github.com/pmmp/ext-pmmpthread/actions/runs/11915925430/job/33207393626
PHP Version
8.3.13
Operating System
ubuntu-20.04 (GitHub Actions)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、ext/opcache/jit/zend_jit_trace.c、zend_jit.c、zend_jit_vm_helpers.c の該当箇所を確認し、zend_jit_trace_hot_root と並行 tracing に注目してください。リンクされているテスト結果をコンテキストとして使用し、opcache.jit=tracing と valgrind --tool=drd で報告を再現してください。複数のスレッドが tracing JIT を実行したときに、報告された race が発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- compilers, performance
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100