Skip to content

Commit 322425e

Browse files
committed
Merge remote-tracking branch 'derickr/GH-10152-serialise-datetime' into PHP-8.2
2 parents 2c8ea44 + 85fbc6e commit 322425e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+877
-36
lines changed

NEWS

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ PHP NEWS
66
. Fixed incorrect check condition in ZEND_YIELD. (nielsdos)
77
. Fixed incorrect check condition in type inference. (nielsdos)
88
. Fix incorrect check in zend_internal_call_should_throw(). (nielsdos)
9+
. Fixed overflow check in OnUpdateMemoryConsumption. (nielsdos)
10+
. Fixed bug GH-9916 (Entering shutdown sequence with a fiber suspended in a
11+
Generator emits an unavoidable fatal error or crashes). (Arnaud)
12+
. Fixed bug GH-10437 (Segfault/assertion when using fibers in shutdown
13+
function after bailout). (trowski)
14+
15+
- Date:
16+
. Fix GH-10152 (Custom properties of Date's child classes are not
17+
serialised). (Derick)
918

1019
- FFI:
1120
. Fixed incorrect bitshifting and masking in ffi bitfield. (nielsdos)
@@ -16,6 +25,9 @@ PHP NEWS
1625
- Opcache:
1726
. Fix incorrect page_size check. (nielsdos)
1827

28+
- Phar:
29+
. Fix incorrect check in phar tar parsing. (nielsdos)
30+
1931
- Random:
2032
. Fix GH-10390 (Do not trust arc4random_buf() on glibc). (timwolla)
2133
. Fix GH-10292 (Made the default value of the first param of srand() and
@@ -551,4 +563,3 @@ PHP NEWS
551563
. On Windows, the Zip extension is now built as shared library (DLL) by
552564
default. (cmb)
553565
. Implement fseek for zip stream when possible with libzip 1.9.1. (Remi)
554-

Zend/Optimizer/zend_inference.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,12 +2569,26 @@ static zend_always_inline zend_result _zend_update_type_info(
25692569
} else if (opline->opcode == ZEND_ASSIGN_OBJ_OP) {
25702570
/* The return value must also satisfy the property type */
25712571
if (prop_info) {
2572-
tmp &= zend_fetch_prop_type(script, prop_info, NULL);
2572+
t1 = zend_fetch_prop_type(script, prop_info, NULL);
2573+
if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG
2574+
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) {
2575+
/* DOUBLE may be auto-converted to LONG */
2576+
tmp |= MAY_BE_LONG;
2577+
tmp &= ~MAY_BE_DOUBLE;
2578+
}
2579+
tmp &= t1;
25732580
}
25742581
} else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP) {
25752582
/* The return value must also satisfy the property type */
25762583
if (prop_info) {
2577-
tmp &= zend_fetch_prop_type(script, prop_info, NULL);
2584+
t1 = zend_fetch_prop_type(script, prop_info, NULL);
2585+
if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG
2586+
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) {
2587+
/* DOUBLE may be auto-converted to LONG */
2588+
tmp |= MAY_BE_LONG;
2589+
tmp &= ~MAY_BE_DOUBLE;
2590+
}
2591+
tmp &= t1;
25782592
}
25792593
} else {
25802594
if (tmp & MAY_BE_REF) {

Zend/tests/fibers/get-return-after-bailout.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
--TEST--
22
Fiber::getReturn() after bailout
3+
--SKIPIF--
4+
<?php
5+
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
6+
if ($zend_mm_enabled === "0") {
7+
die("skip Zend MM disabled");
8+
}
9+
?>
310
--FILE--
411
<?php
512

Zend/tests/fibers/gh10340-001.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug GH-10340 001 (Assertion in zend_fiber_object_gc())
3+
--FILE--
4+
<?php
5+
function f() {
6+
$$y = Fiber::getCurrent();
7+
Fiber::suspend();
8+
}
9+
$fiber = new Fiber(function() {
10+
get_defined_vars();
11+
f();
12+
});
13+
$fiber->start();
14+
gc_collect_cycles();
15+
?>
16+
==DONE==
17+
--EXPECTF--
18+
Warning: Undefined variable $y in %s on line %d
19+
==DONE==

Zend/tests/fibers/gh10340-002.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug GH-10340 002 (Assertion in zend_fiber_object_gc())
3+
--FILE--
4+
<?php
5+
function f() {
6+
$y = 'a';
7+
$$y = Fiber::getCurrent();
8+
Fiber::suspend();
9+
}
10+
$fiber = new Fiber(function() {
11+
get_defined_vars();
12+
f();
13+
});
14+
$fiber->start();
15+
gc_collect_cycles();
16+
?>
17+
==DONE==
18+
--EXPECT--
19+
==DONE==

Zend/tests/fibers/gh10340-003.phpt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
Bug GH-10340 003 (Assertion in zend_fiber_object_gc())
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __destruct() {
8+
echo __METHOD__, "\n";
9+
}
10+
}
11+
12+
function f() {
13+
$c = new C();
14+
$y = 'a';
15+
$$y = Fiber::getCurrent();
16+
Fiber::suspend();
17+
}
18+
19+
$fiber = new Fiber(function() {
20+
get_defined_vars();
21+
f();
22+
});
23+
24+
$fiber->start();
25+
26+
print "1\n";
27+
28+
$fiber = null;
29+
gc_collect_cycles();
30+
31+
print "2\n";
32+
?>
33+
==DONE==
34+
--EXPECT--
35+
1
36+
C::__destruct
37+
2
38+
==DONE==

Zend/tests/fibers/gh10437.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-10437 (Segfault/assertion when using fibers in shutdown function after bailout)
3+
--FILE--
4+
<?php
5+
6+
register_shutdown_function(function (): void {
7+
var_dump(Fiber::getCurrent());
8+
});
9+
10+
$fiber = new Fiber(function (): never {
11+
trigger_error('Bailout in fiber', E_USER_ERROR);
12+
});
13+
$fiber->start();
14+
15+
?>
16+
--EXPECTF--
17+
Fatal error: Bailout in fiber in %sgh10437.php on line %d
18+
NULL

Zend/tests/generators/gh9801.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
Bug GH-9801 (Crash when memory limit is exceeded during generator initialization)
33
--INI--
44
memory_limit=16m
5+
--SKIPIF--
6+
<?php
7+
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
8+
if ($zend_mm_enabled === "0") {
9+
die("skip Zend MM disabled");
10+
}
11+
?>
512
--FILE--
613
<?php
714

Zend/tests/gh9916-001.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug GH-9916 001 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3+
--FILE--
4+
<?php
5+
$gen = (function() {
6+
$x = new stdClass;
7+
try {
8+
print "Before suspend\n";
9+
Fiber::suspend();
10+
print "Not executed";
11+
yield;
12+
} finally {
13+
print "Finally\n";
14+
}
15+
print "Not executed";
16+
})();
17+
$fiber = new Fiber(function() use ($gen, &$fiber) {
18+
$gen->current();
19+
print "Not executed";
20+
});
21+
$fiber->start();
22+
?>
23+
==DONE==
24+
--EXPECT--
25+
Before suspend
26+
==DONE==
27+
Finally

Zend/tests/gh9916-002.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug GH-9916 002 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3+
--FILE--
4+
<?php
5+
$gen = (function() {
6+
$x = new stdClass;
7+
print "Before suspend\n";
8+
Fiber::suspend();
9+
print "Not executed\n";
10+
yield;
11+
})();
12+
$fiber = new Fiber(function() use ($gen, &$fiber) {
13+
$gen->current();
14+
print "Not executed";
15+
});
16+
$fiber->start();
17+
?>
18+
==DONE==
19+
--EXPECT--
20+
Before suspend
21+
==DONE==

Zend/tests/gh9916-003.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Bug GH-9916 003 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3+
--FILE--
4+
<?php
5+
$gen = (function() {
6+
$x = new stdClass;
7+
try {
8+
yield from (function () {
9+
$x = new stdClass;
10+
try {
11+
print "Before suspend\n";
12+
Fiber::suspend();
13+
print "Not executed\n";
14+
yield;
15+
} finally {
16+
print "Finally (inner)\n";
17+
}
18+
})();
19+
print "Not executed\n";
20+
yield;
21+
} finally {
22+
print "Finally\n";
23+
}
24+
})();
25+
$fiber = new Fiber(function() use ($gen, &$fiber) {
26+
$gen->current();
27+
print "Not executed";
28+
});
29+
$fiber->start();
30+
?>
31+
==DONE==
32+
--EXPECT--
33+
Before suspend
34+
==DONE==
35+
Finally (inner)
36+
Finally

Zend/tests/gh9916-004.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug GH-9916 004 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3+
--FILE--
4+
<?php
5+
$gen = (function() {
6+
$x = new stdClass;
7+
yield from (function () {
8+
$x = new stdClass;
9+
print "Before suspend\n";
10+
Fiber::suspend();
11+
print "Not executed\n";
12+
yield;
13+
})();
14+
print "Not executed\n";
15+
yield;
16+
})();
17+
$fiber = new Fiber(function() use ($gen, &$fiber) {
18+
$gen->current();
19+
print "Not executed";
20+
});
21+
$fiber->start();
22+
?>
23+
==DONE==
24+
--EXPECT--
25+
Before suspend
26+
==DONE==

Zend/tests/gh9916-005.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug GH-9916 005 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3+
--FILE--
4+
<?php
5+
$gen = (function() {
6+
$x = new stdClass;
7+
$fiber = yield;
8+
print "Before suspend\n";
9+
Fiber::suspend();
10+
yield;
11+
})();
12+
$fiber = new Fiber(function() use ($gen, &$fiber) {
13+
$gen->send($fiber);
14+
$gen->current();
15+
});
16+
$fiber->start();
17+
18+
$gen = null;
19+
$fiber = null;
20+
gc_collect_cycles();
21+
?>
22+
==DONE==
23+
--EXPECT--
24+
Before suspend
25+
==DONE==

Zend/tests/gh9916-006.phpt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Bug GH-9916 006 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
3+
--FILE--
4+
<?php
5+
$gen = (function() {
6+
$x = new stdClass;
7+
yield from (function () {
8+
$x = new stdClass;
9+
print "Before suspend\n";
10+
Fiber::suspend();
11+
print "After suspend\n";
12+
yield;
13+
})();
14+
yield from (function () {
15+
$x = new stdClass;
16+
print "Before exit\n";
17+
exit;
18+
print "Not executed\n";
19+
yield;
20+
})();
21+
yield;
22+
})();
23+
$fiber = new Fiber(function() use ($gen, &$fiber) {
24+
$gen->current();
25+
print "Fiber return\n";
26+
});
27+
$fiber->start();
28+
$fiber->resume();
29+
$gen->next();
30+
$gen->current();
31+
?>
32+
==DONE==
33+
--EXPECT--
34+
Before suspend
35+
After suspend
36+
Fiber return
37+
Before exit

0 commit comments

Comments
 (0)