From: Christoph M. Becker Date: Fri, 30 Oct 2020 11:44:37 +0000 (+0100) Subject: Fix bug79177.phpt wrt. JIT X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0427dcb91300f993b80c3d77f348d5e1ffcb0d16;p=php Fix bug79177.phpt wrt. JIT JIT ignores that the `zend_write` callback is overwritten, so we define our own callback and caller. We also fix the "inconsistent DLL binding" warnings on Windows, by introducing `PHP_ZEND_TEST_API`. Closes GH-6391. --- diff --git a/ext/ffi/tests/bug79177.phpt b/ext/ffi/tests/bug79177.phpt index d764437b2d..0667faa52d 100644 --- a/ext/ffi/tests/bug79177.phpt +++ b/ext/ffi/tests/bug79177.phpt @@ -2,46 +2,41 @@ Bug #79177 (FFI doesn't handle well PHP exceptions within callback) --SKIPIF-- --FILE-- zend_write; -$php->zend_write = function($str, $len): string { +$ffi->bug79177_cb = function() { throw new \RuntimeException('Not allowed'); }; try { - echo "After\n"; -} catch (\Throwable $exception) { - // Do not output anything here, as handler is overridden -} finally { - $php->zend_write = $originalHandler; -} -if (isset($exception)) { - echo $exception->getMessage(), PHP_EOL; -} + $ffi->bug79177(); // this is supposed to raise a fatal error +} catch (\Throwable $exception) {} +echo "done\n"; ?> --EXPECTF-- -Before - Warning: Uncaught RuntimeException: Not allowed in %s:%d Stack trace: -#0 %s(%d): {closure}('After\n', 6) -#1 {main} +#0 %s(%d): {closure}() +#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 diff --git a/ext/zend_test/php_test.h b/ext/zend_test/php_test.h index da57f7efc9..03e6d836e2 100644 --- a/ext/zend_test/php_test.h +++ b/ext/zend_test/php_test.h @@ -37,7 +37,18 @@ struct bug79096 { uint64_t b; }; -ZEND_API struct bug79096 bug79096(void); -ZEND_API void bug79532(off_t *array, size_t elems); +#ifdef PHP_WIN32 +# define PHP_ZEND_TEST_API __declspec(dllexport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +# define PHP_ZEND_TEST_API __attribute__ ((visibility("default"))) +#else +# define PHP_ZEND_TEST_API +#endif + +PHP_ZEND_TEST_API struct bug79096 bug79096(void); +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 diff --git a/ext/zend_test/test.c b/ext/zend_test/test.c index dfae54e880..4f81adc6ac 100644 --- a/ext/zend_test/test.c +++ b/ext/zend_test/test.c @@ -336,3 +336,9 @@ void bug79532(off_t *array, size_t elems) array[i] = i; } } + +PHP_ZEND_TEST_API int *(*bug79177_cb)(void); +void bug79177(void) +{ + bug79177_cb(); +}