php / php/php-src

JIT trace not invalidated after re-linking

Open
#8,642 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Category: JIT Status: Verified
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

JIT traces are not invalidated after a class is re-linked. The JIT code may make assumptions that are not true anymore after re-linking.

For example, in

<?php

$a=0;

class A implement Iface {
    public function hello() {
        global $a;
        for ($i = 0; $i < 100; $i++) {
            $a++;
        }
    }
}

we may still enter in the JITed loop after A has been re-linked (A can be re-link due to Iface being recompiled for example). The JITed code may be based on assumptions that are not true anymore (at least the run_time_cache pointer changes during linking, but I suspect that other assumptions can be made based on the parent classes or interfaces, that do not hold true after re-linking).

This is due to op_array.oplines being shared between all linked versions of the same class. oplines has pointers to JITed code.

op_array.oplines is also shared between all sub-classes, but as long as the JIT's asumptions are based on the declaring class it should be ok.

PHP Version

PHP 8.1

Operating System

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test is named. Start with the PHP 8.1 example and investigate JIT traces across class re-linking; done means stale JIT code is invalidated so execution cannot retain assumptions from the prior linked class, with regression coverage for the scenario.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.