1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 02:33:17 +02:00
Commit Graph

4154 Commits

Author SHA1 Message Date
Nikita Popov e7a0c5b8c8 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix inference for INIT_ARRAY with illegal offset type
2021-09-29 11:09:22 +02:00
Nikita Popov 944d653b3d Fix inference for INIT_ARRAY with illegal offset type
Extract assign_dim_array_result_type() helper that can be reused
for INIT_ARRAY and implements all this logic correctly.

Fixes oss-fuzz 5156868775870464.
2021-09-29 11:09:04 +02:00
Nikita Popov e1f98447d9 Merge branch 'PHP-8.1'
* PHP-8.1:
  Handle throwing destructor in BIND_STATIC
2021-09-29 10:17:27 +02:00
Nikita Popov 9346da8964 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle throwing destructor in BIND_STATIC
2021-09-29 10:17:22 +02:00
Nikita Popov ec54ffad1e Handle throwing destructor in BIND_STATIC
Fixes oss-fuzz #39406.
2021-09-29 10:17:05 +02:00
Nikita Popov a7ae4926b0 Merge branch 'PHP-8.1'
* PHP-8.1:
  Convert exception during delayed autoload to fatal error
  The PHP-8.1 branch is now for 8.1.0RC4
2021-09-29 10:05:45 +02:00
Nikita Popov c8fa477064 Convert exception during delayed autoload to fatal error
Same as with other exceptions during inheritance, convert those
thrown during delayed class loading into fatal errors. We can't
properly deal with such exceptions, as inheritance cannot be
gracefully aborted at this point.

Fixes oss-fuzz #39405.
2021-09-29 10:03:23 +02:00
Nikita Popov 8b7874b262 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix ASSIGN_DIM result inference with typed refs
  Remove outdated code in ASSIGN_DIM type inference
2021-09-28 14:14:41 +02:00
Nikita Popov 69eb6e04a7 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ASSIGN_DIM result inference with typed refs
  Remove outdated code in ASSIGN_DIM type inference
2021-09-28 14:14:29 +02:00
Nikita Popov 1bb7ee3207 Fix ASSIGN_DIM result inference with typed refs
Same issue as with ASSIGN. Also make the handling for ASSIGN more
precise, we can only have conversions between scalar values.
2021-09-28 14:14:01 +02:00
Nikita Popov 25c264245b Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix type inference and SCCP with typed references
2021-09-28 12:59:33 +02:00
Nikita Popov 2b71df71a1 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix type inference and SCCP with typed references
2021-09-28 12:59:24 +02:00
Nikita Popov d8c2ff6486 Fix type inference and SCCP with typed references
We can't assume that the return value will be the same as the RHS
if typed references are involved.
2021-09-28 12:59:00 +02:00
Nikita Popov 223370e506 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix block marking for two arm math
2021-09-28 10:38:34 +02:00
Nikita Popov 1e4a9a4999 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix block marking for two arm math
2021-09-28 10:38:22 +02:00
Nikita Popov 17d6efc729 Fix block marking for two arm math
This would end up taking the successors_count=2 case, even though
we need to treat SWITCH and MATCH differently. This incorrectly
marked a block as FOLLOW, resulting in incorrect block pass
optimization.

Fixes oss-fuzz #39380.
2021-09-28 10:37:54 +02:00
Nikita Popov 2dd61521f2 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix relative offsets when copying JMPZNZ
2021-09-27 16:20:21 +02:00
Nikita Popov 0015fc9a8e Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix relative offsets when copying JMPZNZ
2021-09-27 16:20:04 +02:00
Nikita Popov 7d483418e2 Fix relative offsets when copying JMPZNZ
This was doing a plain copy of JMPZNZ, even though it encodes
offsets relative to the opline. As such, the offsets would be
relative to target, while they should be relative to opline.
Fix this by recomputing them.

Fixes oss-fuzz #39295.
2021-09-27 16:18:40 +02:00
Nikita Popov 3981f43058 Merge branch 'PHP-8.1'
* PHP-8.1:
  Start block at loop var free
2021-09-27 11:59:03 +02:00
Nikita Popov b86fdf84f0 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Start block at loop var free
2021-09-27 11:58:53 +02:00
Nikita Popov 823888c472 Start block at loop var free
This ensures that code directly before the loop var free is
separated out (and will generally be eliminated as unreachable).
This fixes some assumptions we have that unreachable loop var free
blocks start with the loop var free.

Fixes oss-fuzz #39395.
2021-09-27 11:56:37 +02:00
Nikita Popov 52c6fcbf45 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix DCE of unreachable phi in cycle
2021-09-27 11:27:03 +02:00
Nikita Popov b7ec15f7fe Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix DCE of unreachable phi in cycle
2021-09-27 11:26:56 +02:00
Nikita Popov ddf8910237 Fix DCE of unreachable phi in cycle
We can't remove a trivial phi of the form x = phi(x), because we
don't have a replacement value. We could drop the whole block
though. SCCP would normally do this, but in this particular case
we only determine non-reachability based on type information.

Fixes oss-fuzz #39316.
2021-09-27 11:26:31 +02:00
Nikita Popov 78bd138232 Merge branch 'PHP-8.1'
* PHP-8.1:
  Handle pi nodes in replace_predecessor
2021-09-27 10:48:35 +02:00
Nikita Popov d5e80c1c0c Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle pi nodes in replace_predecessor
2021-09-27 10:48:23 +02:00
Nikita Popov 038bc27787 Handle pi nodes in replace_predecessor
If we're removing a predecessor because it already exists during
replacement, we should also drop pi nodes for that predecessor.

Fixes oss-fuzz #39276.
2021-09-27 10:47:47 +02:00
Nikita Popov 15bbf6f337 Automatically determine whether to reuse get_iterator()
Same as with the IteratorAggregate case, allow reusing get_iterator
if none of the Iterator methods are overridden. Drop the
REUSE_GET_ITERATOR flag that previously allowed ArrayIterator to
opt-in to unconditional get_iterator reuse, and drop the override
handling it did, in favor of the automated approach.
2021-09-24 15:11:26 +02:00
Nikita Popov 1c178569b4 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81465
2021-09-23 14:31:40 +02:00
Nikita Popov a942b284e6 Fixed bug #81465
Make the error message for enum cases more technically correct.
2021-09-23 14:29:27 +02:00
Nikita Popov 982b1498c4 Merge branch 'PHP-8.1'
* PHP-8.1:
  Bail on exception during delayed autoload
2021-09-23 12:47:08 +02:00
Nikita Popov 3991483727 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Bail on exception during delayed autoload
2021-09-23 12:46:56 +02:00
Nikita Popov be8217368b Bail on exception during delayed autoload
We shouldn't try to load further classes if one autoload throws.

This fixes oss-fuzz #38881, though I believe there are still two
deeper issues here: 1) Why do we allow autoloading with an active
exception? 2) Exception save & restore should probably also save
and restore the exception opline.
2021-09-23 12:46:39 +02:00
Nikita Popov 2157d11ddc Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't treat expression exit as terminator
2021-09-23 10:26:34 +02:00
Nikita Popov c9762be566 Don't treat expression exit as terminator
Same as with throw expressions, this may remove later temporary
consuming instructions and thus eliminate live ranges, resulting
in a memory leak. We make use of the same hack and don't consider
exit a terminator if used in an expression context.
2021-09-23 10:26:07 +02:00
Nikita Popov 5ce32368f2 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix SEND_USER with ref arg
2021-09-17 12:18:27 +02:00
Nikita Popov 92f808b8bc Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix SEND_USER with ref arg
2021-09-17 12:18:16 +02:00
Nikita Popov 01453a0af7 Fix SEND_USER with ref arg
Even though the input is not a reference (or not treated as such),
we still need to create a reference to satisfy the function
signature. Various code relies on reference arguments actually
being references. In this particular case, it would result in
a JIT crash.

The zend_call_function() implementation already handled this
correctly.
2021-09-17 12:17:33 +02:00
Nikita Popov 9775677d2d Merge branch 'PHP-8.1'
* PHP-8.1:
  Add missing scope check for readonly prop initialization
2021-09-17 11:20:43 +02:00
Nikita Popov 4796183958 Add missing scope check for readonly prop initialization
If the initializing assignment is an array append we will go through
the UNDEF codepath of get_property_ptr_ptr, which did not verify
that the initialization scope is valid.
2021-09-17 11:20:29 +02:00
Nikita Popov 6446eafb74 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak in array unpack with refcounted numeric string key
2021-09-14 12:14:51 +02:00
Nikita Popov 260d2acdb4 Fix memory leak in array unpack with refcounted numeric string key 2021-09-14 12:14:12 +02:00
Joe Watkins 43876bce5a Merge branch 'PHP-8.1'
* PHP-8.1:
  Allow using readonly as function name
2021-09-13 08:50:54 +02:00
Nikita Popov 76348f3378 Allow using readonly as function name
Don't treat "readonly" as a keyword if followed by "(". This
allows using it as a global function name. In particular, this
function has been used by WordPress.

This does not allow other uses of "readonly", in particular it
cannot be used as a class name, unlike "enum". The reason is that
we'd still have to recognize it as a keyword when using in a type
position:

    class Test {
        public ReadOnly $foo;
    }

This should now be interpreted as a readonly property, not as a
read-write property with type `ReadOnly`. As such, a class with
name `ReadOnly`, while unambiguous in most other circumstances,
would not be usable as property or parameter type. For that
reason, we do not support it at all.
2021-09-13 08:50:32 +02:00
Nikita Popov 5355cf3394 Merge branch 'PHP-8.1'
* PHP-8.1:
  Check that POST_INC/DEC has use in DFA optimization
2021-09-09 15:50:10 +02:00
Nikita Popov f6daf83e75 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Check that POST_INC/DEC has use in DFA optimization
2021-09-09 15:50:04 +02:00
Nikita Popov 5cae6b9b0d Check that POST_INC/DEC has use in DFA optimization
We'd have usually converted it into a PRE_INC if there is no use,
but that's not guaranteed. If there is no use at this point, make
sure we don't try to use the sentinel value.
2021-09-09 15:48:51 +02:00
Nikita Popov 6381a16f3f Avoid use after free in internal prop type verification
This issue only applies to debug builds: read_property can free
the object, but we'd try to check the object handlers afterwards.
Rewrite the check in a way that only accessed the object before
the read_property call.

Fixes oss-fuzz #38297.
2021-09-09 15:30:32 +02:00
Tyson Andre 4c48fd22d7 Fix inconsistency in true/false/null constant resolution when opcache is not used (#7441)
Strangely, uses of eval and 'php -a' (or loading a file without opcache after a namespaced constant was declared)
will not treat non-FQ true/false/null as magic keywords, while compiled php required from a file would do that.

This may confuse people learning the language, and result in code loaded with
eval() behaving differently from the same snippet in a file loaded by require.

```
Interactive shell

php > define('foo\true', 'test');
php > namespace foo { var_dump(true); }
string(4) "test"
```

This will make the same session instead properly emit `bool(true);` like it
already would if running those statements in files when opcache was used.
2021-09-03 08:42:36 -04:00