php / php/php-src

Race conditions on tracing globals in jit-tracing mode in ZTS

Aperta
#16,860 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Category: JIT Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

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)

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia esaminando le posizioni citate in ext/opcache/jit/zend_jit_trace.c, zend_jit.c e zend_jit_vm_helpers.c, concentrandoti su zend_jit_trace_hot_root e sul tracing concorrente. Riproduci il report con opcache.jit=tracing e valgrind --tool=drd usando come contesto i risultati dei test collegati. Il lavoro è completato quando le race segnalate non si verificano più quando più thread eseguono il tracing JIT.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, php
Ambito
compilers, performance
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.