|
|
af9dc8 |
From 3c87945c95c9c31986e690bb046c70e58c8d8896 Mon Sep 17 00:00:00 2001
|
|
|
af9dc8 |
From: Xinchen Hui <laruence@php.net>
|
|
|
af9dc8 |
Date: Wed, 5 Jun 2013 17:25:00 +0800
|
|
|
af9dc8 |
Subject: [PATCH] Fixed bug #64960 (Segfault in gc_zval_possible_root)
|
|
|
af9dc8 |
|
|
|
af9dc8 |
---
|
|
|
af9dc8 |
NEWS | 2 ++
|
|
|
af9dc8 |
Zend/tests/bug64960.phpt | 40 ++++++++++++++++++++++++++++++++++++++++
|
|
|
af9dc8 |
Zend/zend_execute_API.c | 6 ++----
|
|
|
af9dc8 |
3 files changed, 44 insertions(+), 4 deletions(-)
|
|
|
af9dc8 |
create mode 100644 Zend/tests/bug64960.phpt
|
|
|
af9dc8 |
|
|
|
af9dc8 |
diff --git a/Zend/tests/bug64960.phpt b/Zend/tests/bug64960.phpt
|
|
|
af9dc8 |
new file mode 100644
|
|
|
af9dc8 |
index 0000000..b31cca3
|
|
|
af9dc8 |
--- /dev/null
|
|
|
af9dc8 |
+++ b/Zend/tests/bug64960.phpt
|
|
|
af9dc8 |
@@ -0,0 +1,40 @@
|
|
|
af9dc8 |
+--TEST--
|
|
|
af9dc8 |
+Bug #64960 (Segfault in gc_zval_possible_root)
|
|
|
af9dc8 |
+--FILE--
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+// this makes ob_end_clean raise an error
|
|
|
af9dc8 |
+ob_end_flush();
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+class ExceptionHandler {
|
|
|
af9dc8 |
+ public function __invoke (Exception $e)
|
|
|
af9dc8 |
+ {
|
|
|
af9dc8 |
+ // this triggers the custom error handler
|
|
|
af9dc8 |
+ ob_end_clean();
|
|
|
af9dc8 |
+ }
|
|
|
af9dc8 |
+}
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+// this must be a class, closure does not trigger segfault
|
|
|
af9dc8 |
+set_exception_handler(new ExceptionHandler());
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+// exception must be throwed from error handler.
|
|
|
af9dc8 |
+set_error_handler(function()
|
|
|
af9dc8 |
+{
|
|
|
af9dc8 |
+ $e = new Exception;
|
|
|
af9dc8 |
+ $e->_trace = debug_backtrace();
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+ throw $e;
|
|
|
af9dc8 |
+});
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+// trigger error handler
|
|
|
af9dc8 |
+$a['waa'];
|
|
|
af9dc8 |
+?>
|
|
|
af9dc8 |
+--EXPECTF--
|
|
|
af9dc8 |
+Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in %sbug64960.php on line 3
|
|
|
af9dc8 |
+
|
|
|
af9dc8 |
+Fatal error: Uncaught exception 'Exception' in %sbug64960.php:19
|
|
|
af9dc8 |
+Stack trace:
|
|
|
af9dc8 |
+#0 [internal function]: {closure}(8, 'ob_end_clean():...', '%s', 9, Array)
|
|
|
af9dc8 |
+#1 %sbug64960.php(9): ob_end_clean()
|
|
|
af9dc8 |
+#2 [internal function]: ExceptionHandler->__invoke(Object(Exception))
|
|
|
af9dc8 |
+#3 {main}
|
|
|
af9dc8 |
+ thrown in %sbug64960.php on line 19
|
|
|
af9dc8 |
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
|
|
|
af9dc8 |
index 9781889..687520d 100644
|
|
|
af9dc8 |
--- a/Zend/zend_execute_API.c
|
|
|
af9dc8 |
+++ b/Zend/zend_execute_API.c
|
|
|
af9dc8 |
@@ -263,15 +263,13 @@ void shutdown_executor(TSRMLS_D) /* {{{ */
|
|
|
af9dc8 |
if (EG(user_error_handler)) {
|
|
|
af9dc8 |
zeh = EG(user_error_handler);
|
|
|
af9dc8 |
EG(user_error_handler) = NULL;
|
|
|
af9dc8 |
- zval_dtor(zeh);
|
|
|
af9dc8 |
- FREE_ZVAL(zeh);
|
|
|
af9dc8 |
+ zval_ptr_dtor(&zeh;;
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
|
|
|
af9dc8 |
if (EG(user_exception_handler)) {
|
|
|
af9dc8 |
zeh = EG(user_exception_handler);
|
|
|
af9dc8 |
EG(user_exception_handler) = NULL;
|
|
|
af9dc8 |
- zval_dtor(zeh);
|
|
|
af9dc8 |
- FREE_ZVAL(zeh);
|
|
|
af9dc8 |
+ zval_ptr_dtor(&zeh;;
|
|
|
af9dc8 |
}
|
|
|
af9dc8 |
|
|
|
af9dc8 |
zend_stack_destroy(&EG(user_error_handlers_error_reporting));
|
|
|
af9dc8 |
--
|
|
|
af9dc8 |
1.7.11.5
|
|
|
af9dc8 |
|