First commit

This commit is contained in:
Daniil Gentili 2023-10-23 21:59:18 +02:00
commit 5c0a587799
7 changed files with 231 additions and 0 deletions

64
Dockerfile Normal file
View File

@ -0,0 +1,64 @@
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV CC=clang-16
ENV CXX=clang++-16
ENV CFLAGS='-g -fsanitize=address -shared-libasan -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC'
ENV CPPFLAGS='-g -fsanitize=address -shared-libasan -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC'
ENV CXXFLAGS='-g -fsanitize=address -shared-libasan -fno-sanitize-recover -DZEND_TRACK_ARENA_ALLOC'
ENV LDFLAGS='-g -fsanitize=address -shared-libasan -Wl,-rpath=/usr/lib/llvm-16/lib/clang/16/lib/linux/'
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/lib/llvm-16/lib/clang/16/lib/linux/"
RUN true \
&& apt update \
&& apt install -y --no-install-recommends \
tzdata software-properties-common locales curl apt-utils gpg-agent cron logrotate \
gnupg2 ca-certificates lsb-release \
make pkg-config binutils wget \
&& wget https://apt.llvm.org/llvm.sh \
&& chmod +x llvm.sh \
&& ./llvm.sh 16 all \
&& apt update \
\
\
&& apt install -y --no-install-recommends \
nginx \
openssh-client \
git curl xz-utils unzip \
libjpeg62 libjpeg62-dev zlib1g-dev \
libssl-dev libcurl4-openssl-dev \
pkg-config autoconf bison re2c \
libxml2-dev libsqlite3-dev \
systemtap-sdt-dev libssl-dev \
libpcre2-dev libargon2-dev libedit-dev libsodium-dev llvm-16 \
\
&& git clone --depth 1 https://github.com/php/php-src && cd php-src \
\
&& ./buildconf \
&& ./configure --prefix=/usr \
--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/etc \
--localstatedir=/var --libdir=/usr/lib/x86_64-linux-gnu \
--libexecdir=/usr/lib/x86_64-linux-gnu \
--prefix=/usr --enable-cli --disable-cgi --disable-phpdbg \
--with-config-file-path=/etc/php/ --with-config-file-scan-dir=/etc/php/conf.d \
--libdir=/usr/lib/php --libexecdir=/usr/lib/php --datadir=/usr/share/php/8.2 \
--sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man \
--enable-debug --enable-address-sanitizer --disable-rpath --disable-static \
--enable-filter --with-openssl \
--with-password-argon2=/usr --with-external-pcre --with-mhash=/usr --with-libxml \
--enable-session --with-sodium --with-zlib=/usr --with-zlib-dir=/usr \
--enable-pcntl --with-libedit=shared,/usr \
\
&& make -j100 \
&& make install \
&& cd .. && rm -rf php-src
ADD php.ini /etc/php/php.ini
RUN php -r "readfile('https://getcomposer.org/installer');" | php \
&& mv composer.phar /usr/bin/composer
ENV USE_ZEND_ALLOC=0
ENV PSALM_ALLOW_XDEBUG=1

15
bugs/1_psalm.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash -e
cd /tmp
git clone https://github.com/vimeo/psalm
cd psalm
git checkout 7428e49b115a2a837aa29cf0fafd0ca902fe2457
export PSALM_ALLOW_XDEBUG=1
composer i --ignore-platform-reqs
php vendor/bin/phpunit --debug tests/MagicMethodAnnotationTest.php
echo "OK, no bugs!"

80
bugs/2_infection.php Normal file
View File

@ -0,0 +1,80 @@
<?php
require 'vendor/autoload.php';
use Infection\Configuration\Entry\Logs;
use Infection\Configuration\Entry\PhpUnit;
use Infection\Configuration\Entry\Source;
use Infection\Configuration\Schema\SchemaConfiguration;
use Infection\Configuration\Schema\SchemaConfigurationFactory;
use JsonSchema\Validator;
function test_it_can_create_a_config(
string $json,
): void {
$rawConfig = json_decode($json);
$validator = new Validator();
$validator->validate($rawConfig, json_decode('{
"$schema": "https://json-schema.org/draft-07/schema#",
"properties": {
"source": {"type": "string"}
}
}'));
$actual = (new SchemaConfigurationFactory())->create(
'/path/to/config',
$rawConfig
);
}
function provideRawConfig(): iterable
{
yield '[timeout] nominal' => [
<<<'JSON'
{
"timeout": 100,
"source": {
"directories": ["src"]
}
}
JSON
,
];
yield '[logs][text] nominal' => [
<<<'JSON'
{
"source": {
"directories": ["src"]
},
"logs": {
"text": "text.log"
}
}
JSON
,
];
yield '[logs][html] nominal' => [
<<<'JSON'
{
"source": {
"directories": ["src"]
},
"logs": {
"html": "report.html"
}
}
JSON
,
];
}
for ($x = 0; $x < 10000; $x++) {
foreach (provideRawConfig() as [$a]) {
test_it_can_create_a_config($a);
}
}

17
bugs/2_infection.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash -e
#!/bin/bash -e
cd /tmp
git clone https://github.com/infection/infection --depth 1
cd infection
git checkout 2789fdd689689b0c85f2c0ae9db50c8d2b39fb92
composer i --ignore-platform-reqs
php /app/2_infection.php
vendor/bin/phpunit
echo "OK, no bugs!"

15
bugs/3_psalm_new.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash -e
cd /tmp
git clone https://github.com/nicelocal/psalm -b rector_pass --depth 1
cd psalm
git checkout 9d3fee47afa90f3eb53043a26f01e587d2dd34e5
export PSALM_ALLOW_XDEBUG=1
composer i --ignore-platform-reqs
./psalm --no-cache
echo "OK, no bugs!"

32
php.ini Normal file
View File

@ -0,0 +1,32 @@
memory_limit = -1
zend.assertions = 1
display_errors = On
display_startup_errors = On
[opcache]
zend_extension=opcache
opcache.memory_consumption=4096M
opcache.enable=1
opcache.enable_cli=1
opcache.jit=tracing
opcache.validate_timestamps=0
opcache.jit_buffer_size=1G
opcache.file_update_protection=0
opcache.max_accelerated_files=1000000
opcache.interned_strings_buffer=64
;opcache.jit_debug=256
opcache.jit_prof_threshold=0.000000001
opcache.jit_max_root_traces= 30000000
opcache.jit_max_side_traces= 30000000
opcache.jit_max_exit_counters=30000000
opcache.jit_hot_loop=1
opcache.jit_hot_func=1
opcache.jit_hot_return=1
opcache.jit_hot_side_exit=1
opcache.jit_blacklist_root_trace=255
opcache.jit_blacklist_side_trace=255
opcache.protect_memory=1

8
run.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash -e
docker build . -t asan_tests
for f in bugs/*; do
f=$(basename $f)
docker run -v $PWD/bugs:/app --rm --privileged -it asan_tests /app/$f || echo "!!! $f failed !!!"
done