Patch php-5.1.6-apc_deadlock.patch for Reproducible crash Bug #46025
Patch version 2010-05-31 04:50 UTC
Return to Bug #46025 |
Download this patch
Patch Revisions:
Developer: askalski@gmail.com
diff --git a/Zend/zend.c b/Zend/zend.c
index c83e482..464e40e 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -504,6 +504,11 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS
EG(in_autoload) = NULL;
EG(current_execute_data) = NULL;
EG(current_module) = NULL;
+
+ /* {{{ apc deadlock prevention (askalski) */
+ EG(blocking_interruptions) = 0;
+ EG(bailout_deferred) = 0;
+ /* }}} */
}
@@ -771,6 +776,13 @@ ZEND_API void _zend_bailout(char *filename, uint lineno)
{
TSRMLS_FETCH();
+ /* {{{ apc deadlock prevention (askalski) */
+ if (EG(blocking_interruptions)) {
+ EG(bailout_deferred) = 1;
+ return;
+ }
+ /* }}} */
+
if (!EG(bailout_set)) {
zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
exit(-1);
diff --git a/Zend/zend.h b/Zend/zend.h
index d8d5022..07c2860 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -536,8 +536,23 @@ END_EXTERN_C()
#define ZEND_UV(name) (zend_uv.name)
-#define HANDLE_BLOCK_INTERRUPTIONS() if (zend_block_interruptions) { zend_block_interruptions(); }
-#define HANDLE_UNBLOCK_INTERRUPTIONS() if (zend_unblock_interruptions) { zend_unblock_interruptions(); }
+/* {{{ apc deadlock prevention (askalski) */
+#define HANDLE_BLOCK_INTERRUPTIONS() \
+ if (!EG(blocking_interruptions)++) { \
+ if (zend_block_interruptions) { \
+ zend_block_interruptions(); \
+ } \
+ }
+#define HANDLE_UNBLOCK_INTERRUPTIONS() \
+ if (!--EG(blocking_interruptions)) { \
+ if (zend_unblock_interruptions) { \
+ zend_unblock_interruptions(); \
+ } \
+ if (EG(bailout_deferred)) { \
+ zend_bailout(); \
+ } \
+ }
+/* }}} */
BEGIN_EXTERN_C()
ZEND_API void zend_message_dispatcher(long message, void *data);
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index 7c09978..507de8b 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -239,6 +239,11 @@ struct _zend_executor_globals {
zend_property_info std_property_info;
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
+
+ /* {{{ apc deadlock prevention (askalski) */
+ int blocking_interruptions;
+ int bailout_deferred;
+ /* }}} */
};
#include "zend_mm.h"
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index 36dafd6..1560e9a 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -20,6 +20,9 @@
/* $Id: zend_hash.c,v 1.121.2.4 2006/04/07 10:06:21 dmitry Exp $ */
#include "zend.h"
+/* {{{ apc deadlock prevention (askalski) */
+#include "zend_globals.h"
+/* }}} */
#define CONNECT_TO_BUCKET_DLLIST(element, list_head) \
(element)->pNext = (list_head); \
|