Patch php-5.2.13-apc_deadlock.patch for Reproducible crash Bug #46025
Patch version 2010-05-31 04:49 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 1026c08..ce5549a 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -515,6 +515,11 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals TSRMLS
EG(current_module) = NULL;
EG(exit_status) = 0;
EG(active) = 0;
+
+ /* {{{ apc deadlock prevention (askalski) */
+ EG(blocking_interruptions) = 0;
+ EG(bailout_deferred) = 0;
+ /* }}} */
}
@@ -777,6 +782,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)) {
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 0e8c5cc..fc3de81 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -567,8 +567,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 7062825..9b82873 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -240,6 +240,11 @@ struct _zend_executor_globals {
zend_bool active;
void *reserved[ZEND_MAX_RESERVED_RESOURCES];
+
+ /* {{{ apc deadlock prevention (askalski) */
+ int blocking_interruptions;
+ int bailout_deferred;
+ /* }}} */
};
struct _zend_scanner_globals {
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index 875486f..ac9e0b5 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -20,6 +20,9 @@
/* $Id: zend_hash.c 293155 2010-01-05 20:46:53Z sebastian $ */
#include "zend.h"
+/* {{{ apc deadlock prevention (askalski) */
+#include "zend_globals.h"
+/* }}} */
#define CONNECT_TO_BUCKET_DLLIST(element, list_head) \
(element)->pNext = (list_head); \
|