Skip to content

Commit 8690d52

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents e842ddf + 03f0776 commit 8690d52

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ PHP NEWS
4848
- PDO ODBC:
4949
. Fixed bug GH-14367 (incompatible SDWORD type with iODBC). (Calvin Buckley)
5050

51+
- PHPDBG:
52+
. Fixed bug GH-13681 (segfault on watchpoint addition failure). (David Carlier)
53+
5154
- Soap:
5255
. Fixed bug #47925 (PHPClient can't decompress response). (nielsdos)
5356
. Fix missing error restore code. (nielsdos)

sapi/phpdbg/phpdbg_watch.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals) {
315315

316316
struct uffd_msg fault_msg = {0};
317317
while (read(globals->watch_userfaultfd, &fault_msg, sizeof(fault_msg)) == sizeof(fault_msg)) {
318-
void *page = phpdbg_get_page_boundary((char *)(uintptr_t) fault_msg.arg.pagefault.address);
318+
void *page = phpdbg_get_page_boundary((char *)(uintptr_t) fault_msg.arg.pagefault.address);
319319
zend_hash_index_add_empty_element(globals->watchlist_mem, (zend_ulong) page);
320320
struct uffdio_writeprotect unprotect = {
321321
.mode = 0,
@@ -668,7 +668,7 @@ void phpdbg_watch_parent_ht(phpdbg_watch_element *element) {
668668
}
669669

670670
void phpdbg_unwatch_parent_ht(phpdbg_watch_element *element) {
671-
if (element->watch->type == WATCH_ON_BUCKET) {
671+
if (element->watch && element->watch->type == WATCH_ON_BUCKET) {
672672
phpdbg_btree_result *res = phpdbg_btree_find(&PHPDBG_G(watch_HashTables), (zend_ulong) element->parent_container);
673673
ZEND_ASSERT(element->parent_container);
674674
if (res) {
@@ -969,11 +969,14 @@ void phpdbg_remove_watchpoint(phpdbg_watchpoint_t *watch) {
969969
}
970970

971971
void phpdbg_clean_watch_element(phpdbg_watch_element *element) {
972-
HashTable *elements = &element->watch->elements;
973972
phpdbg_unwatch_parent_ht(element);
974-
zend_hash_del(elements, element->str);
975-
if (zend_hash_num_elements(elements) == 0) {
976-
phpdbg_remove_watchpoint(element->watch);
973+
974+
if (element->watch) {
975+
HashTable *elements = &element->watch->elements;
976+
zend_hash_del(elements, element->str);
977+
if (zend_hash_num_elements(elements) == 0) {
978+
phpdbg_remove_watchpoint(element->watch);
979+
}
977980
}
978981
}
979982

sapi/phpdbg/tests/gh13681.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
phpdbg_watch null pointer access
3+
--CREDITS--
4+
Yuancheng Jiang
5+
--SKIPIF--
6+
<?php
7+
if (getenv('SKIP_ASAN')) {
8+
die("skip intentionally causes segfaults");
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
echo "*** Testing array_multisort() : Testing with anonymous arguments ***\n";
14+
var_dump(array_multisort(array(1,3,2,4)));
15+
$xconnect=$GLOBALS[array_rand($GLOBALS)];
16+
echo "Done\n";
17+
$a = [];
18+
$a[0] = 1;
19+
$a[0] = 2;
20+
$a = [0 => 3, 1 => 4];
21+
?>
22+
--PHPDBG--
23+
b 6
24+
r
25+
w a $a
26+
c
27+
q
28+
--EXPECTF--
29+
[Successful compilation of %s]
30+
prompt> [Breakpoint #0 added at %s:%d]
31+
prompt> *** Testing array_multisort() : Testing with anonymous arguments ***
32+
bool(true)
33+
Done
34+
[Breakpoint #0 at %s:%d, hits: 1]
35+
>00006: $a = [];
36+
00007: $a[0] = 1;
37+
00008: $a[0] = 2;
38+
prompt> prompt> [Script ended normally]
39+
prompt>

0 commit comments

Comments
 (0)