|
| 1 | +--TEST-- |
| 2 | +dl() of a frameless function does not keep the freed function record |
| 3 | +--SKIPIF-- |
| 4 | +<?php |
| 5 | +if (PHP_OS_FAMILY === 'Windows') { |
| 6 | + die('skip setarch -R is required so dl() remaps the extension at the stale handler address'); |
| 7 | +} |
| 8 | +if (!getenv('TEST_PHP_CGI_EXECUTABLE')) { |
| 9 | + die('skip php-cgi not available'); |
| 10 | +} |
| 11 | +$setarch = trim((string) shell_exec('command -v setarch')); |
| 12 | +if ($setarch === '') { |
| 13 | + die('skip setarch -R is required so dl() remaps the extension at the stale handler address'); |
| 14 | +} |
| 15 | +$arch = php_uname('m'); |
| 16 | +exec($setarch . ' ' . escapeshellarg($arch) . ' -R true', $setarch_out, $setarch_code); |
| 17 | +if ($setarch_code !== 0) { |
| 18 | + die('skip setarch -R cannot run on ' . $arch); |
| 19 | +} |
| 20 | +$so = ini_get('extension_dir') . DIRECTORY_SEPARATOR . 'dl_test.so'; |
| 21 | +if (!file_exists($so)) { |
| 22 | + die('skip dl_test extension is not built (tried ' . $so . ')'); |
| 23 | +} |
| 24 | +?> |
| 25 | +--FILE-- |
| 26 | +<?php |
| 27 | +$cmd = 'env -u SCRIPT_FILENAME -u PATH_TRANSLATED -u REDIRECT_STATUS -u REQUEST_METHOD -u QUERY_STRING' |
| 28 | + . ' USE_ZEND_ALLOC=0 ASAN_OPTIONS=' . escapeshellarg('detect_leaks=0:halt_on_error=1:abort_on_error=1') |
| 29 | + . ' setarch ' . escapeshellarg(php_uname('m')) . ' -R ' |
| 30 | + . escapeshellarg(getenv('TEST_PHP_CGI_EXECUTABLE')) |
| 31 | + . ' -n -q -T 2 -d enable_dl=1 -d extension_dir=' . escapeshellarg(ini_get('extension_dir')) |
| 32 | + . ' ' . escapeshellarg(__DIR__ . '/frameless_temporary_cgi.inc'); |
| 33 | +$proc = proc_open($cmd, [ |
| 34 | + 0 => ['pipe', 'r'], |
| 35 | + 1 => ['pipe', 'w'], |
| 36 | + 2 => ['pipe', 'w'], |
| 37 | +], $pipes); |
| 38 | +fclose($pipes[0]); |
| 39 | +$out = stream_get_contents($pipes[1]); |
| 40 | +stream_get_contents($pipes[2]); |
| 41 | +fclose($pipes[1]); |
| 42 | +fclose($pipes[2]); |
| 43 | +echo $out; |
| 44 | +$code = proc_close($proc); |
| 45 | +if ($code !== 0) { |
| 46 | + echo "exit:$code\n"; |
| 47 | +} |
| 48 | +?> |
| 49 | +--EXPECT-- |
| 50 | +int(7) |
| 51 | +dl_test_frameless(): Argument #1 ($value) must be of type int, string given |
| 52 | +int(7) |
| 53 | +dl_test_frameless(): Argument #1 ($value) must be of type int, string given |
0 commit comments