php-src/Zend/tests/bug64960.phpt
Tim Düsterhus 08b2ab22f4
Include the source location in Closure names (#13550)
* Include the source location in Closure names

This change makes stack traces involving Closures, especially multiple
different Closures, much more useful, because it's more easily visible *which*
closure was called for a given stack frame.

The implementation is similar to that of anonymous classes which already
include the file name and line number within their generated classname.

* Update scripts/dev/bless_tests.php for closure naming

* Adjust existing tests for closure naming

* Adjust tests for closure naming that were not caught locally

* Drop the namespace from closure names

This is redundant with the included filename.

* Include filename and line number as separate keys in Closure debug info

* Fix test

* Fix test

* Include the surrounding class and function name in closure names

* Fix test

* Relax test expecations

* Fix tests after merge

* NEWS / UPGRADING
2024-04-12 18:21:13 +02:00

45 lines
1.2 KiB
PHP

--TEST--
Bug #64960 (Segfault in gc_zval_possible_root)
--FILE--
<?php
// this makes ob_end_clean raise an error
ob_end_flush();
class ExceptionHandler {
public function __invoke (Exception $e)
{
// this triggers the custom error handler
ob_end_clean();
}
}
// this must be a class, closure does not trigger segfault
set_exception_handler(new ExceptionHandler());
// exception must be thrown from error handler.
set_error_handler(function()
{
$e = new Exception;
$e->_trace = debug_backtrace();
throw $e;
});
// trigger error handler
$a['waa'];
?>
--EXPECTF--
Notice: ob_end_flush(): Failed to delete and flush buffer. No buffer to delete or flush in %sbug64960.php on line 3
Deprecated: Creation of dynamic property Exception::$_trace is deprecated in %s on line %d
Deprecated: Creation of dynamic property Exception::$_trace is deprecated in %s on line %d
Fatal error: Uncaught Exception in %sbug64960.php:19
Stack trace:
#0 [internal function]: {closure:%s:%d}(8, 'ob_end_clean():...', '%s', 9)
#1 %sbug64960.php(9): ob_end_clean()
#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
#3 {main}
thrown in %sbug64960.php on line 19