Created
June 25, 2017 23:45
-
-
Save zsprackett/8197f0242040c2e43d8d800521f09e22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ruN php-5.6.30.orig/Zend/zend_language_scanner.c php-5.6.30/Zend/zend_language_scanner.c | |
--- php-5.6.30.orig/Zend/zend_language_scanner.c 2017-01-18 19:17:47.000000000 -0500 | |
+++ php-5.6.30/Zend/zend_language_scanner.c 2017-06-25 18:47:16.000000000 -0400 | |
@@ -38,6 +38,9 @@ | |
#ifdef PHP_WIN32 | |
# include <Winuser.h> | |
#endif | |
+#ifndef _WIN32 | |
+# include "zend_signal.h" | |
+#endif | |
#include "zend_alloc.h" | |
#include <zend_language_parser.h> | |
#include "zend_compile.h" | |
@@ -125,6 +128,14 @@ | |
BEGIN_EXTERN_C() | |
+#ifndef _WIN32 | |
+static sigjmp_buf sigbus_jmpbuf; | |
+static void sigbus_handler (int sig, siginfo_t *siginfo, void *ptr) | |
+{ | |
+ siglongjmp(sigbus_jmpbuf, 1); | |
+} | |
+#endif | |
+ | |
static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) | |
{ | |
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); | |
@@ -580,6 +591,30 @@ | |
} | |
compilation_successful=0; | |
} else { | |
+#ifndef _WIN32 | |
+ struct sigaction sigbus_signal; | |
+ struct sigaction old_sigbus_signal; | |
+ | |
+ memset(&sigbus_signal, 0, sizeof(sigbus_signal)); | |
+ memset(&old_sigbus_signal, 0, sizeof(old_sigbus_signal)); | |
+ sigbus_signal.sa_sigaction = sigbus_handler; | |
+ sigbus_signal.sa_flags = SA_SIGINFO; | |
+#endif | |
+ | |
+#if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal TSRMLS_CC); } zend_end_try(); | |
+#elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal); | |
+#endif | |
+ | |
+#ifndef _WIN32 | |
+ if (sigsetjmp(sigbus_jmpbuf, 1)) { | |
+ if (file_handle->type != ZEND_HANDLE_STREAM) { | |
+ file_handle->type = ZEND_HANDLE_STREAM; | |
+ } | |
+ } | |
+#endif | |
+ | |
init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); | |
CG(in_compilation) = 1; | |
CG(active_op_array) = op_array; | |
@@ -592,6 +627,12 @@ | |
zend_bailout(); | |
} | |
compilation_successful=1; | |
+ | |
+#if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &old_sigbus_signal, 0 TSRMLS_CC); } zend_end_try(); | |
+#elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &old_sigbus_signal, 0); | |
+#endif | |
} | |
if (retval) { | |
diff -ruN php-5.6.30.orig/Zend/zend_language_scanner.l php-5.6.30/Zend/zend_language_scanner.l | |
--- php-5.6.30.orig/Zend/zend_language_scanner.l 2017-01-18 19:17:47.000000000 -0500 | |
+++ php-5.6.30/Zend/zend_language_scanner.l 2017-06-25 18:46:45.000000000 -0400 | |
@@ -36,6 +36,9 @@ | |
#ifdef PHP_WIN32 | |
# include <Winuser.h> | |
#endif | |
+#ifndef _WIN32 | |
+# include "zend_signal.h" | |
+#endif | |
#include "zend_alloc.h" | |
#include <zend_language_parser.h> | |
#include "zend_compile.h" | |
@@ -123,6 +126,14 @@ | |
BEGIN_EXTERN_C() | |
+#ifndef _WIN32 | |
+static sigjmp_buf sigbus_jmpbuf; | |
+static void sigbus_handler (int sig, siginfo_t *siginfo, void *ptr) | |
+{ | |
+ siglongjmp(sigbus_jmpbuf, 1); | |
+} | |
+#endif | |
+ | |
static size_t encoding_filter_script_to_internal(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length TSRMLS_DC) | |
{ | |
const zend_encoding *internal_encoding = zend_multibyte_get_internal_encoding(TSRMLS_C); | |
@@ -578,6 +589,30 @@ | |
} | |
compilation_successful=0; | |
} else { | |
+#ifndef _WIN32 | |
+ struct sigaction sigbus_signal; | |
+ struct sigaction old_sigbus_signal; | |
+ | |
+ memset(&sigbus_signal, 0, sizeof(sigbus_signal)); | |
+ memset(&old_sigbus_signal, 0, sizeof(old_sigbus_signal)); | |
+ sigbus_signal.sa_sigaction = sigbus_handler; | |
+ sigbus_signal.sa_flags = SA_SIGINFO; | |
+#endif | |
+ | |
+#if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal TSRMLS_CC); } zend_end_try(); | |
+#elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &sigbus_signal, &old_sigbus_signal); | |
+#endif | |
+ | |
+#ifndef _WIN32 | |
+ if (sigsetjmp(sigbus_jmpbuf, 1)) { | |
+ if (file_handle->type != ZEND_HANDLE_STREAM) { | |
+ file_handle->type = ZEND_HANDLE_STREAM; | |
+ } | |
+ } | |
+#endif | |
+ | |
init_op_array(op_array, ZEND_USER_FUNCTION, INITIAL_OP_ARRAY_SIZE TSRMLS_CC); | |
CG(in_compilation) = 1; | |
CG(active_op_array) = op_array; | |
@@ -590,6 +625,12 @@ | |
zend_bailout(); | |
} | |
compilation_successful=1; | |
+ | |
+#if defined(ZEND_SIGNALS) && !defined(_WIN32) | |
+ zend_try { zend_sigaction(SIGBUS, &old_sigbus_signal, 0 TSRMLS_CC); } zend_end_try(); | |
+#elif !defined(_WIN32) | |
+ sigaction(SIGBUS, &old_sigbus_signal, 0); | |
+#endif | |
} | |
if (retval) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is a patch that should apply cleanly to PHP 5.6.33.
https://gist.github.com/robinmulder/916a7b5f059870d1348e4b5423a2ef7e