From 0530dcac3b2d6e8472d9a7a15d488edccfa4bf37 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 24 Oct 2023 10:23:08 +0200 Subject: [PATCH] Fixup --- Dockerfile | 4 ++-- bugs/4_infection.sh | 12 ++++++++++-- bugs/infection.php | 4 +++- bugs/wrap.php | 9 ++++++++- php.ini | 8 ++++---- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4e05f4a..f896ac2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ RUN true \ systemtap-sdt-dev libssl-dev \ libpcre2-dev libargon2-dev libedit-dev libsodium-dev llvm-16 libonig-dev -RUN git clone https://github.com/php/php-src -b master --depth 1 && cd php-src \ +RUN git clone https://github.com/php/php-src -b PHP-8.3 --depth 1 && cd php-src \ \ && ./buildconf \ && ./configure --prefix=/usr \ @@ -67,4 +67,4 @@ ENV USE_ZEND_ALLOC=0 ENV PSALM_ALLOW_XDEBUG=1 ENV ASAN_OPTIONS="detect_leaks=0:exitcode=139" -WORKDIR /app \ No newline at end of file +WORKDIR /app diff --git a/bugs/4_infection.sh b/bugs/4_infection.sh index 1a393d1..ecd09b1 100755 --- a/bugs/4_infection.sh +++ b/bugs/4_infection.sh @@ -19,13 +19,21 @@ cp $wrap . echo "About to run the standalone test" -docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php /app/wrap.php /app/infection.php +EXIT_CODE=0 +docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php /app/wrap.php /app/infection.php || EXIT_CODE=$? + +if [ $EXIT_CODE -ne 0 ]; then + echo "Failed, exit code $EXIT_CODE" + exit $EXIT_CODE +fi echo "About to run the testsuite" -docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php /app/wrap.php vendor/bin/phpunit || EXIT_CODE=$? +EXIT_CODE=0 +docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php --repeat 2 -f /app/wrap.php vendor/bin/phpunit || EXIT_CODE=$? if [ $EXIT_CODE -gt 128 ]; then + echo "Failed, exit code $EXIT_CODE" exit $EXIT_CODE fi diff --git a/bugs/infection.php b/bugs/infection.php index fae7bae..2d9a823 100644 --- a/bugs/infection.php +++ b/bugs/infection.php @@ -77,4 +77,6 @@ for ($x = 0; $x < 10000; $x++) { foreach (provideRawConfig() as [$a]) { test_it_can_create_a_config($a); } -} \ No newline at end of file +} + +echo "OK, done!"; \ No newline at end of file diff --git a/bugs/wrap.php b/bugs/wrap.php index c8b0ec9..120b39d 100644 --- a/bugs/wrap.php +++ b/bugs/wrap.php @@ -4,21 +4,28 @@ register_shutdown_function(function () { $status = opcache_get_status(false); var_dump($status); + $ok = true; if ($status["memory_usage"]["free_memory"] < 10*1024*1024) { echo "Not enough free opcache memory!".PHP_EOL; + $ok = false; } if ($status["interned_strings_usage"]["free_memory"] < 1*1024*1024) { echo "Not enough free interned strings memory!".PHP_EOL; + $ok = false; } if ($status["jit"]["buffer_free"] < 10*1024*1024) { echo "Not enough free JIT memory!".PHP_EOL; + $ok = false; } if (!$status["jit"]["on"]) { echo "JIT is not enabled!".PHP_EOL; + $ok = false; } unset($status); gc_collect_cycles(); + + if (!$ok) die(139); }); $argc--; @@ -27,4 +34,4 @@ array_shift($argv); $_SERVER['argc']--; array_shift($_SERVER['argv']); -require $argv[0]; \ No newline at end of file +require $argv[0]; diff --git a/php.ini b/php.ini index f53e31a..e81b53d 100644 --- a/php.ini +++ b/php.ini @@ -15,9 +15,9 @@ opcache.max_accelerated_files=1000000 opcache.interned_strings_buffer=64 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_max_root_traces= 10000000 +opcache.jit_max_side_traces= 10000000 +opcache.jit_max_exit_counters=10000000 opcache.jit_hot_loop=1 opcache.jit_hot_func=1 opcache.jit_hot_return=1 @@ -26,4 +26,4 @@ opcache.jit_hot_side_exit=1 opcache.jit_blacklist_root_trace=255 opcache.jit_blacklist_side_trace=255 -opcache.protect_memory=1 \ No newline at end of file +opcache.protect_memory=1