1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/ffi/tests/bug79177.phpt
Christoph M. Becker db991bc0f1 FFI: support symbol lookup without specifying lib on Windows
This works similar to `dlsym(RTLD_DEFAULT, …)` with the caveat that
symbols on Windows may not be unique, and are usually qualified by the
module they are exported from.  That means that wrong symbols may be
fetched, potentially causing serious issues; therefore this usage is
not recommended for production purposes, but is a nice simplification
for quick experiments and the ext/ffi test suite.

Closes GH-16351.
2024-10-19 15:36:49 +02:00

31 lines
689 B
PHP

--TEST--
Bug #79177 (FFI doesn't handle well PHP exceptions within callback)
--EXTENSIONS--
ffi
zend_test
--FILE--
<?php
$header = <<<HEADER
extern int *(*bug79177_cb)(void);
void bug79177(void);
HEADER;
$ffi = FFI::cdef($header);
$ffi->bug79177_cb = function() {
throw new \RuntimeException('Not allowed');
};
try {
$ffi->bug79177(); // this is supposed to raise a fatal error
} catch (\Throwable $exception) {}
echo "done\n";
?>
--EXPECTF--
Warning: Uncaught RuntimeException: Not allowed in %s:%d
Stack trace:
#0 %s(%d): {closure:%s:%d}()
#1 %s(%d): FFI->bug79177()
#2 {main}
thrown in %s on line %d
Fatal error: Throwing from FFI callbacks is not allowed in %s on line %d