Skip to content

Commit 3c87945

Browse files
committed
Fixed bug #64960 (Segfault in gc_zval_possible_root)
1 parent 93e0d78 commit 3c87945

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2013, PHP 5.3.27
4+
- Core:
5+
. Fixed bug #64960 (Segfault in gc_zval_possible_root). (Laruence)
46

57
- PDO_firebird:
68
. Fixed bug #64037 (Firebird return wrong value for numeric field).

Zend/tests/bug64960.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Bug #64960 (Segfault in gc_zval_possible_root)
3+
--FILE--
4+
<?php
5+
// this makes ob_end_clean raise an error
6+
ob_end_flush();
7+
8+
class ExceptionHandler {
9+
public function __invoke (Exception $e)
10+
{
11+
// this triggers the custom error handler
12+
ob_end_clean();
13+
}
14+
}
15+
16+
// this must be a class, closure does not trigger segfault
17+
set_exception_handler(new ExceptionHandler());
18+
19+
// exception must be throwed from error handler.
20+
set_error_handler(function()
21+
{
22+
$e = new Exception;
23+
$e->_trace = debug_backtrace();
24+
25+
throw $e;
26+
});
27+
28+
// trigger error handler
29+
$a['waa'];
30+
?>
31+
--EXPECTF--
32+
Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %sbug64960.php on line 3
33+
34+
Fatal error: Uncaught exception 'Exception' in %sbug64960.php:19
35+
Stack trace:
36+
#0 [internal function]: {closure}(8, 'ob_end_clean():...', '%s', 9, Array)
37+
#1 %sbug64960.php(9): ob_end_clean()
38+
#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
39+
#3 {main}
40+
thrown in %sbug64960.php on line 19

Zend/zend_execute_API.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,13 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
263263
if (EG(user_error_handler)) {
264264
zeh = EG(user_error_handler);
265265
EG(user_error_handler) = NULL;
266-
zval_dtor(zeh);
267-
FREE_ZVAL(zeh);
266+
zval_ptr_dtor(&zeh);
268267
}
269268

270269
if (EG(user_exception_handler)) {
271270
zeh = EG(user_exception_handler);
272271
EG(user_exception_handler) = NULL;
273-
zval_dtor(zeh);
274-
FREE_ZVAL(zeh);
272+
zval_ptr_dtor(&zeh);
275273
}
276274

277275
zend_stack_destroy(&EG(user_error_handlers_error_reporting));

0 commit comments

Comments
 (0)