Skip to content

Commit 3c36c73

Browse files
committed
sapi/phpdbg: windows update exception type falling into segfault.
close GH-15098
1 parent 1ca3230 commit 3c36c73

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.4.0beta1
44

5+
- PHPDBG:
6+
. array out of bounds, stack overflow handled for segfault handler on windows.
7+
(David Carlier)
8+
59

610
01 Aug 2024, PHP 8.4.0alpha4
711

sapi/phpdbg/phpdbg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ int main(int argc, char **argv) /* {{{ */
16271627

16281628
#ifdef _WIN32
16291629
} __except(phpdbg_exception_handler_win32(xp = GetExceptionInformation())) {
1630-
phpdbg_error("Access violation (Segmentation fault) encountered\ntrying to abort cleanly...");
1630+
phpdbg_error("Segmentation fault encountered\ntrying to abort cleanly...");
16311631
}
16321632
#endif
16331633
phpdbg_out:

sapi/phpdbg/phpdbg_win.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ int phpdbg_exception_handler_win32(EXCEPTION_POINTERS *xp) {
2828
EXCEPTION_RECORD *xr = xp->ExceptionRecord;
2929
CONTEXT *xc = xp->ContextRecord;
3030

31-
if(xr->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) {
32-
33-
if (phpdbg_watchpoint_segfault_handler((void *)xr->ExceptionInformation[1]) == SUCCESS) {
34-
return EXCEPTION_CONTINUE_EXECUTION;
35-
}
31+
switch (xr->ExceptionCode) {
32+
case EXCEPTION_ACCESS_VIOLATION:
33+
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
34+
case EXCEPTION_STACK_OVERFLOW:
35+
if (phpdbg_watchpoint_segfault_handler((void *)xr->ExceptionInformation[1]) == SUCCESS) {
36+
return EXCEPTION_CONTINUE_EXECUTION;
37+
}
38+
break;
39+
EMPTY_SWITCH_DEFAULT_CASE()
3640
}
3741

3842
return EXCEPTION_CONTINUE_SEARCH;

0 commit comments

Comments
 (0)