#include "ext/standard/info.h"
#include "php_variables.h"
#include "php_ini.h"
-#include "ext/standard/head.h"
#ifdef WITH_ZEUS
# include "httpext.h"
#define ISAPI_POST_DATA_BUF 1024
static zend_bool bFilterLoaded=0;
-static zend_bool bIgnoreCrashes=0;
+static zend_bool bTerminateThreadsOnError=0;
static char *isapi_special_server_variable_names[] = {
"ALL_HTTP",
|| zend_startup_module(&php_isapi_module)==FAILURE) {
return FAILURE;
} else {
- bIgnoreCrashes = (zend_bool) INI_INT("isapi.ignore_crashes");
+ bTerminateThreadsOnError = (zend_bool) INI_INT("isapi.terminate_threads_on_error");
return SUCCESS;
}
}
}
-#ifdef PHP_WIN32
-static int php_isapi_exception_handler(LPEXCEPTION_POINTERS ep TSRMLS_DC)
+static void my_endthread()
{
- if (ep->ExceptionRecord->ExceptionCode==EXCEPTION_STACK_OVERFLOW) {
- return EXCEPTION_EXECUTE_HANDLER;
+#ifdef PHP_WIN32
+ if (bTerminateThreadsOnError) {
+ _endthread();
}
- if (ep->ExceptionRecord->ExceptionCode==EXCEPTION_ACCESS_VIOLATION) {
- char buf[1024];
-
- _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Access Violation at %p", ep->ExceptionRecord->ExceptionAddress);
- php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC);
- } else {
- char buf[1024];
+#endif
+}
- _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p", ep->ExceptionRecord->ExceptionCode , ep->ExceptionRecord->ExceptionAddress);
- php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC);
- }
- if (bIgnoreCrashes) {
- return EXCEPTION_CONTINUE_SEARCH;
- } else {
- exit(-1);
- }
+#ifdef PHP_WIN32
+/* ep is accessible only in the context of the __except expression,
+ * so we have to call this function to obtain it.
+ */
+BOOL exceptionhandler(LPEXCEPTION_POINTERS *e, LPEXCEPTION_POINTERS ep)
+{
+ *e=ep;
+ return TRUE;
}
#endif
{
zend_file_handle file_handle;
zend_bool stack_overflown=0;
+#ifdef PHP_ENABLE_SEH
+ LPEXCEPTION_POINTERS e;
+#endif
TSRMLS_FETCH();
zend_first_try {
efree(SG(request_info).cookie_data);
}
#ifdef PHP_ENABLE_SEH
- } __except(php_isapi_exception_handler(GetExceptionInformation() TSRMLS_CC)) {
- /* we only trap stack overflow exceptions */
- if (_exception_code() == EXCEPTION_STACK_OVERFLOW) {
+ } __except(exceptionhandler(&e, GetExceptionInformation())) {
+ char buf[1024];
+ if (_exception_code()==EXCEPTION_STACK_OVERFLOW) {
LPBYTE lpPage;
static SYSTEM_INFO si;
static MEMORY_BASIC_INFORMATION mi;
}
CG(unclean_shutdown)=1;
- php_header();
- sapi_isapi_ub_write("Stack overflow", sizeof("Stack overflow")-1 TSRMLS_CC);
+ _snprintf(buf, sizeof(buf)-1,"PHP has encountered a Stack overflow");
+ php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC);
+ } else if (_exception_code()==EXCEPTION_ACCESS_VIOLATION) {
+ _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Access Violation at %p", e->ExceptionRecord->ExceptionAddress);
+ php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC);
+ my_endthread();
+ } else {
+ _snprintf(buf, sizeof(buf)-1,"PHP has encountered an Unhandled Exception Code %d at %p", e->ExceptionRecord->ExceptionCode , e->ExceptionRecord->ExceptionAddress);
+ php_isapi_report_exception(buf, strlen(buf) TSRMLS_CC);
+ my_endthread();
}
#endif
}
#ifdef PHP_ENABLE_SEH
__try {
php_request_shutdown(NULL);
- } __except(php_isapi_exception_handler(GetExceptionInformation() TSRMLS_CC)) {
- /* We should only get to this block in case of a stack overflow,
- * which is very unlikely
- */
+ } __except(EXCEPTION_EXECUTE_HANDLER) {
+ my_endthread();
}
#else
php_request_shutdown(NULL);