From 2f8ce947868ee21f882fdaf85930d86eaaaa6a02 Mon Sep 17 00:00:00 2001 From: Florian Engelhardt Date: Fri, 22 May 2026 13:39:34 +0200 Subject: [PATCH] ASAN test for #3898 --- .../tests/phpt/preload_ini_zts_asan.phpt | 34 +++++++++++++++++++ .../phpt/preload_ini_zts_asan_preload.php | 3 ++ 2 files changed, 37 insertions(+) create mode 100644 profiling/tests/phpt/preload_ini_zts_asan.phpt create mode 100644 profiling/tests/phpt/preload_ini_zts_asan_preload.php diff --git a/profiling/tests/phpt/preload_ini_zts_asan.phpt b/profiling/tests/phpt/preload_ini_zts_asan.phpt new file mode 100644 index 00000000000..a2aba966a13 --- /dev/null +++ b/profiling/tests/phpt/preload_ini_zts_asan.phpt @@ -0,0 +1,34 @@ +--TEST-- +[profiling] ASAN regression: ZTS preloading must not duplicate INI values from themselves +--DESCRIPTION-- +During preloading in ZTS builds, EG(ini_directives) is still the global INI +table. The ZTS INI synchronization step must be skipped in that state. If it is +not skipped, it releases zend_ini_entry.value and then duplicates the same +pointer, which ASAN reports as a use-after-free. +--ENV-- +USE_ZEND_ALLOC=0 +DD_PROFILING_ENABLED=0 +DD_PROFILING_LOG_LEVEL=error +--SKIPIF-- += 7.4.0\n"; +if (!extension_loaded('datadog-profiling')) + echo "skip: test requires datadog-profiling\n"; +if (!extension_loaded('Zend OPcache')) + echo "skip: test requires opcache\n"; +?> +--INI-- +opcache.enable_cli=1 +opcache.preload={PWD}/preload_ini_zts_asan_preload.php +opcache.preload_user=root +--FILE-- + +--EXPECTREGEX-- +^(?:\[TRACE datadog_php_profiling\] MINIT\([0-9]+, [0-9]+\)\n)*preload ini ok: yes\nmain ini ok: yes\n?$ diff --git a/profiling/tests/phpt/preload_ini_zts_asan_preload.php b/profiling/tests/phpt/preload_ini_zts_asan_preload.php new file mode 100644 index 00000000000..2f113ad60c1 --- /dev/null +++ b/profiling/tests/phpt/preload_ini_zts_asan_preload.php @@ -0,0 +1,3 @@ +