Skip to content

Inform the type when reporting the error: Illegal offset type #10450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 144 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
91227c5
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
009945f
Merge branch 'php:master' into master
marcosmarcolin Dec 17, 2022
ba36a49
Merge branch 'php:master' into master
marcosmarcolin Dec 19, 2022
0386041
Merge branch 'php:master' into master
marcosmarcolin Dec 20, 2022
d6e7c73
Merge branch 'php:master' into master
marcosmarcolin Dec 21, 2022
d47eca9
Merge branch 'php:master' into master
marcosmarcolin Dec 23, 2022
b131d30
Merge branch 'php:master' into master
marcosmarcolin Dec 26, 2022
b84c549
Merge branch 'php:master' into master
marcosmarcolin Dec 26, 2022
64a9793
Merge branch 'php:master' into master
marcosmarcolin Dec 29, 2022
1afee9a
Merge branch 'php:master' into master
marcosmarcolin Jan 2, 2023
072c44e
Merge branch 'php:master' into master
marcosmarcolin Jan 3, 2023
fa8ace8
Merge branch 'php:master' into master
marcosmarcolin Jan 5, 2023
20a34b7
Merge branch 'php:master' into master
marcosmarcolin Jan 6, 2023
431c1b3
Merge branch 'php:master' into master
marcosmarcolin Jan 6, 2023
9d5d563
Merge branch 'php:master' into master
marcosmarcolin Jan 7, 2023
a42d498
Merge branch 'php:master' into master
marcosmarcolin Jan 8, 2023
053f026
Merge branch 'php:master' into master
marcosmarcolin Jan 9, 2023
93ebbd5
Merge branch 'php:master' into master
marcosmarcolin Jan 9, 2023
62d6514
Merge branch 'php:master' into master
marcosmarcolin Jan 10, 2023
e649783
Merge branch 'php:master' into master
marcosmarcolin Jan 11, 2023
70892a7
Merge branch 'php:master' into master
marcosmarcolin Jan 13, 2023
dbef9c3
Merge branch 'php:master' into master
marcosmarcolin Jan 14, 2023
7a9c2b4
Merge branch 'php:master' into master
marcosmarcolin Jan 15, 2023
6567de0
Merge branch 'php:master' into master
marcosmarcolin Jan 16, 2023
366b22a
Merge branch 'php:master' into master
marcosmarcolin Jan 17, 2023
f684963
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
cedca52
Merge branch 'php:master' into master
marcosmarcolin Jan 17, 2023
80aa081
Merge branch 'php:master' into master
marcosmarcolin Jan 18, 2023
aaff3fa
Merge branch 'php:master' into master
marcosmarcolin Jan 20, 2023
8707dec
Merge branch 'php:master' into master
marcosmarcolin Jan 23, 2023
f553344
Merge branch 'php:master' into master
marcosmarcolin Jan 23, 2023
0f72482
Merge branch 'php:master' into master
marcosmarcolin Jan 23, 2023
8de0e9d
Merge branch 'php:master' into master
marcosmarcolin Jan 24, 2023
cf523fa
Merge branch 'php:master' into master
marcosmarcolin Jan 25, 2023
cb12bed
inform the type in the array displacement error message.
marcosmarcolin Jan 25, 2023
0717f23
inform the type in the array displacement error message.
marcosmarcolin Jan 25, 2023
dba7099
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
9416328
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
821d856
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
f96b1aa
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
a8ad5c8
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
45c755c
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
1173c2e
Prevent dtor of generator in suspended fiber (#10462)
arnaud-lb Jan 27, 2023
d7de73b
Fix overflow check in OnUpdateMemoryConsumption (#10456)
nielsdos Jan 27, 2023
a24ac59
[ci skip] NEWS
arnaud-lb Jan 27, 2023
6c22dea
Merge branch 'PHP-8.1' into PHP-8.2
arnaud-lb Jan 27, 2023
cfb6e82
[ci skip] NEWS
arnaud-lb Jan 27, 2023
479b47c
Merge branch 'PHP-8.2'
arnaud-lb Jan 27, 2023
4901fd6
Merge branch 'master' of https://github.com/marcosmarcolin/php-src in…
marcosmarcolin Jan 27, 2023
aeca4d2
Prevent dtor of generator in suspended fiber (#10462)
arnaud-lb Jan 27, 2023
63cac95
Fix overflow check in OnUpdateMemoryConsumption (#10456)
nielsdos Jan 27, 2023
be68ced
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
2e1d1f0
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
f9e5a17
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
4b812e4
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
1d4b18e
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
adf0d4f
Revert "Fix overflow check in OnUpdateMemoryConsumption (#10456)"
marcosmarcolin Jan 27, 2023
4e3808b
Revert "Prevent dtor of generator in suspended fiber (#10462)"
marcosmarcolin Jan 27, 2023
e789645
fix: handle JIT helper.
marcosmarcolin Jan 27, 2023
dc6fbec
Fix missing zend_shared_alloc_unlock() (#10405)
nielsdos Jan 28, 2023
306a72a
Add test for GH-10405
arnaud-lb Jan 28, 2023
d5e4ec4
fix: also treat isset and empty
marcosmarcolin Jan 28, 2023
284c293
Fix GH-10437: Set active fiber to null on bailout (#10443)
trowski Jan 28, 2023
0c4aee4
Merge branch 'PHP-8.1' into PHP-8.2
trowski Jan 28, 2023
5e1b966
[ci skip] NEWS
trowski Jan 28, 2023
ff84598
Merge branch 'PHP-8.2'
trowski Jan 28, 2023
ec4939b
Fix incorrect check in phar tar parsing
nielsdos Jan 27, 2023
08f654b
Merge branch 'PHP-8.1' into PHP-8.2
Girgias Jan 29, 2023
231ffaf
Merge branch 'PHP-8.2'
Girgias Jan 29, 2023
908d954
sockets updlite protocol support, with checksum coverage settings.
devnexen Jan 28, 2023
81607a6
Fix type inference
dstogov Jan 30, 2023
55e3f73
Merge branch 'PHP-8.1' into PHP-8.2
dstogov Jan 30, 2023
ea37abd
Merge branch 'PHP-8.2'
dstogov Jan 30, 2023
b9bca2d
Fix resetting ZEND_GENERATOR_IN_FIBER flag
bwoebi Jan 30, 2023
e746b89
Merge branch 'PHP-8.1' into PHP-8.2
bwoebi Jan 30, 2023
1679235
Merge branch 'PHP-8.2'
bwoebi Jan 30, 2023
00be6e1
Look at executing generator for fiber destructor behaviour
bwoebi Jan 30, 2023
f732486
Merge branch 'PHP-8.1' into PHP-8.2
bwoebi Jan 30, 2023
8076ca2
Merge branch 'PHP-8.2'
bwoebi Jan 30, 2023
3eb9dd4
Use bool and zend_result where it makes sense in sockets extension
Girgias Dec 21, 2021
735edd1
Voidify php_sock_array_from_fd_set() as result is never used
Girgias Dec 21, 2021
f71e8bf
fix: change function name for standardization.
marcosmarcolin Jan 31, 2023
85fbc6e
Fix GH-10152: Custom properties of Date's child classes are not seria…
derickr Jan 25, 2023
322425e
Merge remote-tracking branch 'derickr/GH-10152-serialise-datetime' in…
derickr Jan 31, 2023
71766d7
Merge branch 'PHP-8.2'
derickr Jan 31, 2023
a42bf93
Fixed GH-10447: 'p' format specifier does not yield 'Z' for 00:00
derickr Jan 26, 2023
d17175c
Merge remote-tracking branch 'derickr/GH-10447-p-format-specifier' in…
derickr Jan 31, 2023
cb907d5
Merge branch 'PHP-8.1' into PHP-8.2
derickr Jan 31, 2023
8d5953c
Merge branch 'PHP-8.2'
derickr Jan 31, 2023
328cce4
fix: change location of functions and apply in ext/spl.
marcosmarcolin Jan 31, 2023
f0ff97b
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
7efd90a
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
92edc84
inform the type in the array displacement error message.
marcosmarcolin Jan 25, 2023
7eba815
inform the type in the array displacement error message.
marcosmarcolin Jan 25, 2023
a63e9de
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
be17096
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
a19d295
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
6d24bb7
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
e51f09d
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
998a5dd
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
2d73ebb
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
6271040
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
74bf5d8
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
6dbaa72
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
f8cd06f
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
e04ccc9
Revert "Fix overflow check in OnUpdateMemoryConsumption (#10456)"
marcosmarcolin Jan 27, 2023
83d8284
Revert "Prevent dtor of generator in suspended fiber (#10462)"
marcosmarcolin Jan 27, 2023
3238768
fix: handle JIT helper.
marcosmarcolin Jan 27, 2023
620b5f6
fix: also treat isset and empty
marcosmarcolin Jan 28, 2023
9b70b6e
fix: change function name for standardization.
marcosmarcolin Jan 31, 2023
58d12ad
fix: change location of functions and apply in ext/spl.
marcosmarcolin Jan 31, 2023
dcca7e8
Merge remote-tracking branch 'origin/array-illegal-offset-message' in…
marcosmarcolin Jan 31, 2023
959f395
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
1e77b4e
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
0890300
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
a352953
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
2a70b36
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
7354aa5
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
90360f4
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
ce0ecc9
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
0776d35
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
4503ff7
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
1232aaf
inform the type in the array displacement error message.
marcosmarcolin Jan 25, 2023
4f3991a
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
e6c4efe
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
9d43616
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
15d2132
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
c62de15
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
1bf8ce7
Prevent dtor of generator in suspended fiber (#10462)
arnaud-lb Jan 27, 2023
fc6b26a
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
b9d6b6b
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
f7bb931
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
7bc2583
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
71540ea
inform the type in the array displacement error message.
marcosmarcolin Jan 27, 2023
3fd18aa
Revert "Prevent dtor of generator in suspended fiber (#10462)"
marcosmarcolin Jan 27, 2023
84f9c49
fix: handle JIT helper.
marcosmarcolin Jan 27, 2023
8dba14a
fix: also treat isset and empty
marcosmarcolin Jan 28, 2023
7209798
fix: change function name for standardization.
marcosmarcolin Jan 31, 2023
1c1d822
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
f983b02
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
dca199d
chore: unnecessary parentheses.
marcosmarcolin Dec 16, 2022
e9a048a
Revert "chore: unnecessary parentheses."
marcosmarcolin Jan 17, 2023
14b6e34
fix: test
marcosmarcolin Jan 31, 2023
1396f8f
Merge branch 'array-illegal-offset-message' into offset-illegal-array…
marcosmarcolin Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ PHP NEWS
ACK delays. (David Carlier)
. Added DONTFRAGMENT support for path MTU discovery purpose. (David Carlier)
. Added AF_DIVERT for raw socket for divert ports. (David Carlier)
. Added SOL_UPDLITE, UDPLITE_RECV_CSCOV and UDPLITE_SEND_CSCOV for updlite
protocol support. (David Carlier)

- Standard:
. E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla)
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ PHP 8.3 UPGRADE NOTES
. IP_PMTUDISC_INTERFACE (Linux only).
. IP_PMTUDISC_OMIT (Linux only).
. AF_DIVERT (FreeBSD only).
. SOL_UDPLITE.
. UDPLITE_RECV_CSCOV.
. UDPLITE_SEND_CSCOV.

========================================
11. Changes to INI File Handling
Expand Down
18 changes: 16 additions & 2 deletions Zend/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -2569,12 +2569,26 @@ static zend_always_inline zend_result _zend_update_type_info(
} else if (opline->opcode == ZEND_ASSIGN_OBJ_OP) {
/* The return value must also satisfy the property type */
if (prop_info) {
tmp &= zend_fetch_prop_type(script, prop_info, NULL);
t1 = zend_fetch_prop_type(script, prop_info, NULL);
if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) {
/* DOUBLE may be auto-converted to LONG */
tmp |= MAY_BE_LONG;
tmp &= ~MAY_BE_DOUBLE;
}
tmp &= t1;
}
} else if (opline->opcode == ZEND_ASSIGN_STATIC_PROP_OP) {
/* The return value must also satisfy the property type */
if (prop_info) {
tmp &= zend_fetch_prop_type(script, prop_info, NULL);
t1 = zend_fetch_prop_type(script, prop_info, NULL);
if ((t1 & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_LONG
&& (tmp & (MAY_BE_LONG|MAY_BE_DOUBLE)) == MAY_BE_DOUBLE) {
/* DOUBLE may be auto-converted to LONG */
tmp |= MAY_BE_LONG;
tmp &= ~MAY_BE_DOUBLE;
}
tmp &= t1;
}
} else {
if (tmp & MAY_BE_REF) {
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/036.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ try {

?>
--EXPECT--
Illegal offset type
Cannot access offset of type object on array
2 changes: 1 addition & 1 deletion Zend/tests/038.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ try {

?>
--EXPECT--
Illegal offset type
Cannot access offset of type object on array
8 changes: 4 additions & 4 deletions Zend/tests/assign_dim_obj_null_return.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ test();
?>
--EXPECT--
Cannot add element to the array as the next element is already occupied
Illegal offset type
Illegal offset type
Cannot access offset of type array on array
Cannot access offset of type object on array
Cannot use a scalar value as an array
Cannot add element to the array as the next element is already occupied
Illegal offset type
Illegal offset type
Cannot access offset of type array on array
Cannot access offset of type object on array
Cannot use a scalar value as an array
Attempt to assign property "foo" on true
Attempt to assign property "foo" on true
2 changes: 1 addition & 1 deletion Zend/tests/bug79790.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function b($a = array()[array ()]) {
}
?>
--EXPECTF--
Fatal error: Uncaught TypeError: Illegal offset type in %s:%d
Fatal error: Uncaught TypeError: Cannot access offset of type array on array in %s:%d
Stack trace:
#0 %s(%d): b()
#1 {main}
Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug79947.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ try {
var_dump($array);
?>
--EXPECT--
Illegal offset type
Cannot access offset of type array on array
array(0) {
}
2 changes: 1 addition & 1 deletion Zend/tests/bug80781.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (isset($array[$data]) or getPlugin($data)) {

?>
--EXPECTF--
Fatal error: Uncaught TypeError: Illegal offset type in isset or empty in %s:%d
Fatal error: Uncaught TypeError: Cannot access offset of type array in isset or empty in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const C2 = [C1, [] => 1];

?>
--EXPECTF--
Fatal error: Uncaught TypeError: Illegal offset type in %s:%d
Fatal error: Uncaught TypeError: Cannot access offset of type array on array in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
7 changes: 7 additions & 0 deletions Zend/tests/fibers/get-return-after-bailout.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
--TEST--
Fiber::getReturn() after bailout
--SKIPIF--
<?php
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
if ($zend_mm_enabled === "0") {
die("skip Zend MM disabled");
}
?>
--FILE--
<?php

Expand Down
18 changes: 18 additions & 0 deletions Zend/tests/fibers/gh10437.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
GH-10437 (Segfault/assertion when using fibers in shutdown function after bailout)
--FILE--
<?php

register_shutdown_function(function (): void {
var_dump(Fiber::getCurrent());
});

$fiber = new Fiber(function (): never {
trigger_error('Bailout in fiber', E_USER_ERROR);
});
$fiber->start();

?>
--EXPECTF--
Fatal error: Bailout in fiber in %sgh10437.php on line %d
NULL
7 changes: 7 additions & 0 deletions Zend/tests/generators/gh9801.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Bug GH-9801 (Crash when memory limit is exceeded during generator initialization)
--INI--
memory_limit=16m
--SKIPIF--
<?php
$zend_mm_enabled = getenv("USE_ZEND_ALLOC");
if ($zend_mm_enabled === "0") {
die("skip Zend MM disabled");
}
?>
--FILE--
<?php

Expand Down
17 changes: 17 additions & 0 deletions Zend/tests/gh9916-012.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug GH-9916 012 (Entering shutdown sequence with a fiber suspended in a Generator emits an unavoidable fatal error or crashes)
--FILE--
<?php

$gen = (function() {
yield from (function() { yield; })();
})();
$fiber = new Fiber(function() use ($gen) {
$gen->current();
});
$fiber->start();

?>
==DONE==
--EXPECT--
==DONE==
6 changes: 3 additions & 3 deletions Zend/tests/illegal_offset_unset_isset_empty.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ try {

?>
--EXPECT--
Illegal offset type in unset
Illegal offset type in isset or empty
Illegal offset type in isset or empty
Cannot access offset of type array on unset
Cannot access offset of type array in isset or empty
Cannot access offset of type array in isset or empty
2 changes: 1 addition & 1 deletion Zend/tests/init_array_illegal_offset_type.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ try {
}
?>
--EXPECT--
Illegal offset type
Cannot access offset of type object on array
4 changes: 2 additions & 2 deletions Zend/tests/isset_array.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ bool(false)

Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
bool(false)
Illegal offset type in isset or empty
Illegal offset type in isset or empty
Cannot access offset of type array in isset or empty
Cannot access offset of type object in isset or empty
13 changes: 11 additions & 2 deletions Zend/tests/offset_array.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ try {
echo $e->getMessage(), "\n";
}

try{
$k = [];
$arr = ['foo'];
$arr[$k];
}catch (Error $e){
echo $e->getMessage(), "\n";
}

echo "Done\n";
?>
--EXPECTF--
Expand All @@ -48,6 +56,7 @@ int(1)

Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
int(%d)
Illegal offset type
Illegal offset type
Cannot access offset of type object on array
Cannot access offset of type array on array
Cannot access offset of type array on array
Done
15 changes: 15 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -2046,6 +2046,21 @@ ZEND_API zend_result add_next_index_reference(zval *arg, zend_reference *ref) /*
}
/* }}} */

void zend_illegal_empty_or_isset_offset(const zval *offset)
{
zend_type_error("Cannot access offset of type %s in isset or empty", zend_get_type_by_const(Z_TYPE_P(offset)));
}

void zend_illegal_unset_offset(const zval *offset)
{
zend_type_error("Cannot access offset of type %s on unset", zend_get_type_by_const(Z_TYPE_P(offset)));
}

void zend_illegal_array_offset(const zval *offset)
{
zend_type_error("Cannot access offset of type %s on array", zend_get_type_by_const(Z_TYPE_P(offset)));
}

ZEND_API zend_result array_set_zval_key(HashTable *ht, zval *key, zval *value) /* {{{ */
{
zval *result;
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -8752,6 +8752,7 @@ static bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
default:
zend_error_noreturn(E_COMPILE_ERROR, "Illegal offset type");
break;

}
} else if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), value)) {
zval_ptr_dtor_nogc(value);
Expand Down
11 changes: 3 additions & 8 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1455,11 +1455,6 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(v
zend_throw_error(NULL, "Cannot use object as array");
}

static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_offset(void)
{
zend_type_error("Illegal offset type");
}

static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_string_offset(const zval *offset)
{
zend_type_error("Cannot access offset of type %s on string", zend_zval_type_name(offset));
Expand Down Expand Up @@ -2329,7 +2324,7 @@ static zend_never_inline zend_uchar slow_index_convert(HashTable *ht, const zval
value->lval = 1;
return IS_LONG;
default:
zend_illegal_offset();
zend_illegal_array_offset(dim);
return IS_NULL;
}
}
Expand Down Expand Up @@ -2403,7 +2398,7 @@ static zend_never_inline zend_uchar slow_index_convert_w(HashTable *ht, const zv
value->lval = 1;
return IS_LONG;
default:
zend_illegal_offset();
zend_illegal_array_offset(dim);
return IS_NULL;
}
}
Expand Down Expand Up @@ -2985,7 +2980,7 @@ static zend_never_inline bool ZEND_FASTCALL zend_array_key_exists_fast(HashTable
str = ZSTR_EMPTY_ALLOC();
goto str_key;
} else {
zend_illegal_offset();
zend_illegal_array_offset(key);
return 0;
}
}
Expand Down
1 change: 1 addition & 0 deletions Zend/zend_fibers.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ static zend_always_inline zend_fiber_transfer zend_fiber_switch_to(

/* Forward bailout into current fiber. */
if (UNEXPECTED(transfer.flags & ZEND_FIBER_TRANSFER_FLAG_BAILOUT)) {
EG(active_fiber) = NULL;
zend_bailout();
}

Expand Down
8 changes: 8 additions & 0 deletions Zend/zend_generators.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ static void zend_generator_dtor_storage(zend_object *object) /* {{{ */
uint32_t op_num, try_catch_offset;
int i;

/* Generator is running in a suspended fiber.
* Will be dtor during fiber dtor */
if (zend_generator_get_current(generator)->flags & ZEND_GENERATOR_IN_FIBER) {
/* Prevent finally blocks from yielding */
generator->flags |= ZEND_GENERATOR_FORCED_CLOSE;
return;
}

/* leave yield from mode to properly allow finally execution */
if (UNEXPECTED(Z_TYPE(generator->values) != IS_UNDEF)) {
zval_ptr_dtor(&generator->values);
Expand Down
4 changes: 2 additions & 2 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -6055,7 +6055,7 @@ ZEND_VM_C_LABEL(num_index):
str = ZSTR_EMPTY_ALLOC();
ZEND_VM_C_GOTO(str_index);
} else {
zend_illegal_offset();
zend_illegal_array_offset(offset);
zval_ptr_dtor_nogc(expr_ptr);
}
FREE_OP2();
Expand Down Expand Up @@ -6571,7 +6571,7 @@ ZEND_VM_C_LABEL(num_index_dim):
key = ZSTR_EMPTY_ALLOC();
ZEND_VM_C_GOTO(str_index_dim);
} else {
zend_type_error("Illegal offset type in unset");
zend_illegal_unset_offset(offset);
}
break;
} else if (Z_ISREF_P(container)) {
Expand Down
Loading