mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix bug79177.phpt wrt. JIT
This commit is contained in:
commit
72d9d9b88f
@ -2,46 +2,41 @@
|
|||||||
Bug #79177 (FFI doesn't handle well PHP exceptions within callback)
|
Bug #79177 (FFI doesn't handle well PHP exceptions within callback)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
require_once('skipif.inc');
|
if (!extension_loaded('ffi')) die('skip ffi extension not available');
|
||||||
require_once('utils.inc');
|
if (!extension_loaded('zend-test')) die('skip zend-test extension not available');
|
||||||
try {
|
|
||||||
ffi_cdef("extern void *zend_printf;", ffi_get_php_dll_name());
|
|
||||||
} catch (Throwable $e) {
|
|
||||||
die('skip PHP symbols not available');
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once('utils.inc');
|
require_once __DIR__ . '/utils.inc';
|
||||||
$php = ffi_cdef("
|
$header = <<<HEADER
|
||||||
typedef char (*zend_write_func_t)(const char *str, size_t str_length);
|
extern int *(*bug79177_cb)(void);
|
||||||
extern zend_write_func_t zend_write;
|
void bug79177(void);
|
||||||
", ffi_get_php_dll_name());
|
HEADER;
|
||||||
|
|
||||||
echo "Before\n";
|
if (PHP_OS_FAMILY !== 'Windows') {
|
||||||
|
$ffi = FFI::cdef($header);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
$ffi = FFI::cdef($header, 'php_zend_test.dll');
|
||||||
|
} catch (FFI\Exception $ex) {
|
||||||
|
$ffi = FFI::cdef($header, ffi_get_php_dll_name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$originalHandler = clone $php->zend_write;
|
$ffi->bug79177_cb = function() {
|
||||||
$php->zend_write = function($str, $len): string {
|
|
||||||
throw new \RuntimeException('Not allowed');
|
throw new \RuntimeException('Not allowed');
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
echo "After\n";
|
$ffi->bug79177(); // this is supposed to raise a fatal error
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {}
|
||||||
// Do not output anything here, as handler is overridden
|
echo "done\n";
|
||||||
} finally {
|
|
||||||
$php->zend_write = $originalHandler;
|
|
||||||
}
|
|
||||||
if (isset($exception)) {
|
|
||||||
echo $exception->getMessage(), PHP_EOL;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECTF--
|
||||||
Before
|
|
||||||
|
|
||||||
Warning: Uncaught RuntimeException: Not allowed in %s:%d
|
Warning: Uncaught RuntimeException: Not allowed in %s:%d
|
||||||
Stack trace:
|
Stack trace:
|
||||||
#0 %s(%d): {closure}('After\n', 6)
|
#0 %s(%d): {closure}()
|
||||||
#1 {main}
|
#1 %s(%d): FFI->bug79177()
|
||||||
|
#2 {main}
|
||||||
thrown in %s on line %d
|
thrown in %s on line %d
|
||||||
|
|
||||||
Fatal error: Throwing from FFI callbacks is not allowed in %s on line %d
|
Fatal error: Throwing from FFI callbacks is not allowed in %s on line %d
|
||||||
|
@ -36,16 +36,17 @@ struct bug79096 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
# ifdef PHP_ZEND_TEST_EXPORTS
|
# define PHP_ZEND_TEST_API __declspec(dllexport)
|
||||||
# define PHP_ZEND_TEST_API __declspec(dllexport)
|
#elif defined(__GNUC__) && __GNUC__ >= 4
|
||||||
# else
|
# define PHP_ZEND_TEST_API __attribute__ ((visibility("default")))
|
||||||
# define PHP_ZEND_TEST_API __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# define PHP_ZEND_TEST_API ZEND_API
|
# define PHP_ZEND_TEST_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PHP_ZEND_TEST_API struct bug79096 bug79096(void);
|
PHP_ZEND_TEST_API struct bug79096 bug79096(void);
|
||||||
PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems);
|
PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems);
|
||||||
|
|
||||||
|
extern PHP_ZEND_TEST_API int *(*bug79177_cb)(void);
|
||||||
|
PHP_ZEND_TEST_API void bug79177(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -620,3 +620,9 @@ PHP_ZEND_TEST_API void bug79532(off_t *array, size_t elems)
|
|||||||
array[i] = i;
|
array[i] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PHP_ZEND_TEST_API int *(*bug79177_cb)(void);
|
||||||
|
void bug79177(void)
|
||||||
|
{
|
||||||
|
bug79177_cb();
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user