mirror of
https://github.com/danog/jit_bugs.git
synced 2024-11-26 12:04:52 +01:00
Update
This commit is contained in:
parent
cbdb72bf3f
commit
b4780afc13
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/vendor/
|
@ -53,8 +53,7 @@ RUN git clone https://github.com/php/php-src -b master --depth 1 && cd php-src \
|
|||||||
&& export LDFLAGS='-g -fsanitize=address -shared-libasan -Wl,-rpath=/usr/lib/llvm-16/lib/clang/16/lib/linux/' \
|
&& export LDFLAGS='-g -fsanitize=address -shared-libasan -Wl,-rpath=/usr/lib/llvm-16/lib/clang/16/lib/linux/' \
|
||||||
\
|
\
|
||||||
&& make -j100 \
|
&& make -j100 \
|
||||||
&& make install \
|
&& make install
|
||||||
&& cd .. && rm -rf php-src
|
|
||||||
|
|
||||||
ADD php.ini /etc/php/php.ini
|
ADD php.ini /etc/php/php.ini
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ Tested on fa218eab4a9b5304afb871a4405546068cb65008
|
|||||||
1. Composer: always fails
|
1. Composer: always fails
|
||||||
2. Psalm: always fails
|
2. Psalm: always fails
|
||||||
3. MadelineProto: got a single shutdown hang the first time I tried (even with the new closure fixes), then nothing; expecting an assertion crash
|
3. MadelineProto: got a single shutdown hang the first time I tried (even with the new closure fixes), then nothing; expecting an assertion crash
|
||||||
4. Infection: used to fail on some older php-src commit, now doesn't, still including it in order to play around with branches
|
4. Infection (patched): always fails
|
||||||
5. Psalm (unit): hang due to infinite loop in GC
|
5. Psalm (unit): hang due to infinite loop in GC
|
||||||
6. php-parser (unit): always fails
|
6. php-parser (unit): always fails
|
||||||
|
7. Psalm (master, unit): always fails
|
||||||
|
8. Psalm (patched master, unit): always fails
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
standalone=$PWD/bugs/wrap_madeline.php
|
standalone=$PWD/bugs/wrap_madeline.php
|
||||||
|
|
||||||
|
refactor=$PWD/refactor.php
|
||||||
|
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
|
||||||
rm -rf jit_test
|
rm -rf jit_test
|
||||||
@ -13,4 +15,6 @@ cd jit_test
|
|||||||
|
|
||||||
cp $standalone wrap.php
|
cp $standalone wrap.php
|
||||||
|
|
||||||
docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php -d opcache.blacklist_filename=b.txt -f /app/wrap.php test.php
|
php $refactor
|
||||||
|
|
||||||
|
docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php --repeat 2 -d opcache.blacklist_filename=b.txt -f /app/wrap.php test.php
|
@ -1,9 +1,8 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
#!/bin/bash -e
|
|
||||||
|
|
||||||
wrap=$PWD/bugs/wrap.php
|
wrap=$PWD/bugs/wrap.php
|
||||||
standalone=$PWD/bugs/infection.php
|
standalone=$PWD/bugs/infection.php
|
||||||
|
refactor=$PWD/refactor.php
|
||||||
|
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
|
||||||
@ -14,6 +13,8 @@ cd infection
|
|||||||
|
|
||||||
composer i --ignore-platform-reqs
|
composer i --ignore-platform-reqs
|
||||||
|
|
||||||
|
php $refactor
|
||||||
|
|
||||||
cp $standalone .
|
cp $standalone .
|
||||||
cp $wrap .
|
cp $wrap .
|
||||||
|
|
||||||
|
27
bugs/7_psalm_master.sh
Executable file
27
bugs/7_psalm_master.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
standalone=$PWD/bugs/wrap.php
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
|
||||||
|
rm -rf psalm_7
|
||||||
|
|
||||||
|
git clone https://github.com/nicelocal/psalm -b master psalm_7
|
||||||
|
cd psalm_7
|
||||||
|
git checkout c7d7b48bdd798b404976054d1b5220082c2f246e
|
||||||
|
|
||||||
|
git branch -D master || true
|
||||||
|
git branch master
|
||||||
|
git checkout master
|
||||||
|
|
||||||
|
export PSALM_ALLOW_XDEBUG=1
|
||||||
|
|
||||||
|
cp $standalone .
|
||||||
|
|
||||||
|
composer i --ignore-platform-reqs
|
||||||
|
|
||||||
|
echo "About to run psalm"
|
||||||
|
|
||||||
|
docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php --repeat 2 -f /app/wrap.php /app/psalm --no-cache
|
||||||
|
|
||||||
|
echo "OK, no bugs!"
|
30
bugs/8_psalm_master_refactor.sh
Executable file
30
bugs/8_psalm_master_refactor.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
standalone=$PWD/bugs/wrap.php
|
||||||
|
refactor=$PWD/refactor.php
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
|
||||||
|
rm -rf psalm_8
|
||||||
|
|
||||||
|
git clone https://github.com/nicelocal/psalm -b master psalm_8
|
||||||
|
cd psalm_8
|
||||||
|
git checkout c7d7b48bdd798b404976054d1b5220082c2f246e
|
||||||
|
|
||||||
|
git branch -D master || true
|
||||||
|
git branch master
|
||||||
|
git checkout master
|
||||||
|
|
||||||
|
export PSALM_ALLOW_XDEBUG=1
|
||||||
|
|
||||||
|
cp $standalone .
|
||||||
|
|
||||||
|
composer i --ignore-platform-reqs
|
||||||
|
|
||||||
|
echo "About to run psalm"
|
||||||
|
|
||||||
|
php $refactor
|
||||||
|
|
||||||
|
docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php --repeat 2 -f /app/wrap.php /app/psalm --no-cache
|
||||||
|
|
||||||
|
echo "OK, no bugs!"
|
17
composer.json
Normal file
17
composer.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"name": "daniil/jit_bugs",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Daniil\\JitBugs\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Daniil Gentili",
|
||||||
|
"email": "daniil@daniil.it"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"nikic/php-parser": "^4.17"
|
||||||
|
}
|
||||||
|
}
|
75
composer.lock
generated
Normal file
75
composer.lock
generated
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"_readme": [
|
||||||
|
"This file locks the dependencies of your project to a known state",
|
||||||
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
|
"This file is @generated automatically"
|
||||||
|
],
|
||||||
|
"content-hash": "d34d57dc247d3a323a479c321530d36a",
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "nikic/php-parser",
|
||||||
|
"version": "v4.17.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/nikic/PHP-Parser.git",
|
||||||
|
"reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
|
||||||
|
"reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-tokenizer": "*",
|
||||||
|
"php": ">=7.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ircmaxell/php-yacc": "^0.0.7",
|
||||||
|
"phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/php-parse"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "4.9-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"PhpParser\\": "lib/PhpParser"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Nikita Popov"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "A PHP parser written in PHP",
|
||||||
|
"keywords": [
|
||||||
|
"parser",
|
||||||
|
"php"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||||
|
"source": "https://github.com/nikic/PHP-Parser/tree/v4.17.1"
|
||||||
|
},
|
||||||
|
"time": "2023-08-13T19:53:39+00:00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"packages-dev": [],
|
||||||
|
"aliases": [],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"stability-flags": [],
|
||||||
|
"prefer-stable": false,
|
||||||
|
"prefer-lowest": false,
|
||||||
|
"platform": [],
|
||||||
|
"platform-dev": [],
|
||||||
|
"plugin-api-version": "2.6.0"
|
||||||
|
}
|
46
refactor.php
Normal file
46
refactor.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use PhpParser\Node\Expr\Array_;
|
||||||
|
use PhpParser\Node\Expr\ArrayItem;
|
||||||
|
use PhpParser\Node\Expr\ArrowFunction;
|
||||||
|
use PhpParser\Node\Expr\Variable;
|
||||||
|
use PhpParser\Node\FunctionLike;
|
||||||
|
use PhpParser\Node\Scalar\LNumber;
|
||||||
|
use PhpParser\Node\Stmt\Foreach_;
|
||||||
|
use PhpParser\NodeFinder;
|
||||||
|
use PhpParser\NodeTraverser;
|
||||||
|
use PhpParser\NodeVisitor\NameResolver;
|
||||||
|
use PhpParser\ParserFactory;
|
||||||
|
use PhpParser\PrettyPrinter\Standard;
|
||||||
|
|
||||||
|
require __DIR__.'/vendor/autoload.php';
|
||||||
|
|
||||||
|
$i = new RecursiveDirectoryIterator($argv[1] ?? '.');
|
||||||
|
$i = new RecursiveIteratorIterator($i);
|
||||||
|
$i = new RegexIterator($i, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
|
||||||
|
|
||||||
|
$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
|
||||||
|
$finder = new NodeFinder;
|
||||||
|
$resolver = new NodeTraverser(new NameResolver());
|
||||||
|
$printer = new Standard();
|
||||||
|
|
||||||
|
foreach ($i as [$file]) {
|
||||||
|
$f = file_get_contents($file);
|
||||||
|
try {
|
||||||
|
$parsed = $resolver->traverse($parser->parse($f));
|
||||||
|
} catch (\Throwable) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($finder->findInstanceOf($parsed, FunctionLike::class) as $f) {
|
||||||
|
if ($f instanceof ArrowFunction) continue;
|
||||||
|
if ($f->stmts === null) continue;
|
||||||
|
$f->stmts = [new Foreach_(
|
||||||
|
new Array_([new ArrayItem(new LNumber(0))]),
|
||||||
|
new Variable('_'),
|
||||||
|
['stmts' => $f->stmts]
|
||||||
|
)];
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($file, $printer->prettyPrintFile($parsed));
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user