From 81abca2c1dd20d26565f5301371eb0fa70e9cbe4 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 24 Jul 2024 21:03:04 +0100 Subject: [PATCH] sapi/phpdbg: windows update exception type falling into segfault. --- sapi/phpdbg/phpdbg.c | 2 +- sapi/phpdbg/phpdbg_win.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 6528c6f2c2fd3..d09ededc1d6bf 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1627,7 +1627,7 @@ int main(int argc, char **argv) /* {{{ */ #ifdef _WIN32 } __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) { - phpdbg_error("Access violation (Segmentation fault) encountered\ntrying to abort cleanly..."); + phpdbg_error("Segmentation fault encountered\ntrying to abort cleanly..."); } #endif phpdbg_out: diff --git a/sapi/phpdbg/phpdbg_win.c b/sapi/phpdbg/phpdbg_win.c index 95cacfe6ff5c5..349d9c6261e35 100644 --- a/sapi/phpdbg/phpdbg_win.c +++ b/sapi/phpdbg/phpdbg_win.c @@ -28,11 +28,15 @@ int phpdbg_exception_handler_win32(EXCEPTION_POINTERS *xp) { EXCEPTION_RECORD *xr = xp->ExceptionRecord; CONTEXT *xc = xp->ContextRecord; - if(xr->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) { - - if (phpdbg_watchpoint_segfault_handler((void *)xr->ExceptionInformation[1]) == SUCCESS) { - return EXCEPTION_CONTINUE_EXECUTION; - } + switch (xr->ExceptionCode) { + case EXCEPTION_ACCESS_VIOLATION: + case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: + case EXCEPTION_STACK_OVERFLOW: + if (phpdbg_watchpoint_segfault_handler((void *)xr->ExceptionInformation[1]) == SUCCESS) { + return EXCEPTION_CONTINUE_EXECUTION; + } + break; + EMPTY_SWITCH_DEFAULT_CASE() } return EXCEPTION_CONTINUE_SEARCH;