php / php-src

The PHP Interpreter
https://www.php.net
Other
38.3k stars 7.76k forks source link

8.4 function JIT memory corruption #16913

Closed danog closed 1 day ago

danog commented 3 days ago

Description

Multiple tests in the psalm testsuite (master branch) fail with function JIT enabled on 8.4:

PHP Version

8.4

Operating System

No response

danog commented 3 days ago

Ping @dstogov, reproducer in https://github.com/vimeo/psalm/actions/runs/11995605450/job/33439072858

dstogov commented 2 days ago

I can't reproduce this:

$ ../../php8.4/CGI-DEBUG-64/sapi/cli/php -d opcache.jit=function vendor/bin/phpunit tests/LanguageServer/CompletionTest.php
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.

Random Seed:   1732546680

..............................................                    46 / 46 (100%)

Time: 01:55.105, Memory: 690.00 MB

OK (46 tests, 102 assertions)

$ ../../php8.4/CGI-DEBUG-64/sapi/cli/php -d opcache.jit=function vendor/bin/phpunit tests/FileUpdates/ErrorAfterUpdateTest.php 
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.

Random Seed:   1732546964

......................                                            22 / 22 (100%)

Time: 00:05.661, Memory: 116.00 MB

OK (22 tests, 44 assertions

$ ../../php8.4/CGI-DEBUG-64/sapi/cli/php -d opcache.jit=function vendor/bin/phpunit -v tests/UnusedVariableTest.php 
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.1-dev
Configuration: /home/dmitry/php/community_tests/psalm/phpunit.xml.dist
Random Seed:   1732544955

....................................................S....S.....  63 / 293 ( 21%)
..S......S...........S.........................S............... 126 / 293 ( 43%)
............................................................... 189 / 293 ( 64%)
............................................................... 252 / 293 ( 86%)
.........................................                       293 / 293 (100%)

Time: 09:21.384, Memory: 124.50 MB

There were 6 skipped tests:

1) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-warnAboutVariableUsedInNestedTryNotUsedInOuterTry" ('<?php\n                    $s...      ', 'UnusedVariable')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

2) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-unusedReferenceInDestructuredForeach" ('<?php\n                    fo...      ', 'UnusedForeachValue')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

3) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-byrefInForeachLoopWithoutReference" ('<?php\n                    $a...     }', 'UnusedVariable')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

4) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-unusedGlobalVariable" ('<?php\n                    $a...      ', 'UnusedVariable - src/somefile...1 - $a')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

5) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-unusedReferenceToSubsequentlyUsedVariable" ('<?php\n                    $a...      ', 'UnusedVariable - src/somefile...1 - $b')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

6) Psalm\Tests\UnusedVariableTest::testValidCode with data set "SKIPPED-referenceUsedInDestructuredForeach" ('<?php\n                    fo...      ')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/ValidCodeAnalysisTestTrait.php:62

OK, but incomplete, skipped, or risky tests!
Tests: 293, Assertions: 373, Skipped: 6.

$ ../../php8.4/CGI-DEBUG-64/sapi/cli/php -d opcache.jit=0 vendor/bin/phpunit -v tests/UnusedVariableTest.php 
PHPUnit 9.6.21 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.1-dev
Configuration: /home/dmitry/php/community_tests/psalm/phpunit.xml.dist
Random Seed:   1732545823

..............................................S................  63 / 293 ( 21%)
............................................................... 126 / 293 ( 43%)
............................................................... 189 / 293 ( 64%)
..............................S.............................S.. 252 / 293 ( 86%)
..S.................S.................S..                       293 / 293 (100%)

Time: 13:16.966, Memory: 126.50 MB

There were 6 skipped tests:

1) Psalm\Tests\UnusedVariableTest::testValidCode with data set "SKIPPED-referenceUsedInDestructuredForeach" ('<?php\n                    fo...      ')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/ValidCodeAnalysisTestTrait.php:62

2) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-unusedReferenceToSubsequentlyUsedVariable" ('<?php\n                    $a...      ', 'UnusedVariable - src/somefile...1 - $b')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

3) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-warnAboutVariableUsedInNestedTryNotUsedInOuterTry" ('<?php\n                    $s...      ', 'UnusedVariable')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

4) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-unusedGlobalVariable" ('<?php\n                    $a...      ', 'UnusedVariable - src/somefile...1 - $a')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

5) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-unusedReferenceInDestructuredForeach" ('<?php\n                    fo...      ', 'UnusedForeachValue')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

6) Psalm\Tests\UnusedVariableTest::testInvalidCode with data set "SKIPPED-byrefInForeachLoopWithoutReference" ('<?php\n                    $a...     }', 'UnusedVariable')
Skipped due to a bug.

/home/dmitry/php/community_tests/psalm/tests/Traits/InvalidCodeAnalysisTestTrait.php:63

OK, but incomplete, skipped, or risky tests!
Tests: 293, Assertions: 373, Skipped: 6.
danog commented 2 days ago

@dstogov reproduced using https://github.com/danog/jit_bugs/blob/master/bugs/15_psalm.sh

danog commented 2 days ago

Just for context, running on an x86-64-v3 machine (no avx512, only avx2)