1
0
mirror of https://github.com/php/php-src.git synced 2026-04-21 15:08:16 +02:00
Commit Graph

125639 Commits

Author SHA1 Message Date
Nikita Popov fa3d603ba2 Mark ASSIGN result as UNUSED in SCCP
We can't drop the ASSIGN entirely, but we should mark the result
as UNUSED. Otherwise we'll replace uses of it in operands and
will not free the ASSIGN result value. This can happen with
non-interned strings, but possibly there's some other cases that
can trigger this as well.
2021-09-14 13:16: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
Nikita Popov e7de9b2091 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix func/class name use after free on opcache OOM condition
2021-09-14 12:03:03 +02:00
Nikita Popov 10e9f6b340 Fix func/class name use after free on opcache OOM condition
This can occur on opcache OOM conditions, where the function/class
names are not interned and the script does not get cached. In
that case the functions/classes get transferred from the persistent
script to the global tables, without incrementing the key refcount.
To mirror that, we should also not try to free the keys when freeing
the persistent script. For this by setting the number of elements
to zero, which will free only the hashtable structure itself.
2021-09-14 12:00:44 +02:00
Nikita Popov a2fc14c14f Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix BIND_STATIC may_throw check
2021-09-14 10:10:51 +02:00
Nikita Popov 1b376b06fb Fix BIND_STATIC may_throw check
This is supposed to index into arData, not the HashTable itself.
2021-09-14 10:09:32 +02:00
Tyson Andre 27976d7dc7 Merge branch 'PHP-8.0' into PHP-8.1 2021-09-13 21:18:56 -04:00
Tyson Andre 753645a6f8 Merge remote-tracking branch 'origin/PHP-7.4' into PHP-8.0 2021-09-13 21:00:53 -04:00
Tyson Andre b053192a03 Fix #81429: Handle resizing in SplFixedArray::offsetSet (#7487)
offsetSet did not account for the fact that the array may no longer exist after
the field is overwritten. This fixes that.

Add test of resizing both to the empty array and a smaller array - there should
be no valgrind warnings with a proper fix.

Alternate approach to #7486 (described in https://bugs.php.net/bug.php?id=81429)
2021-09-13 20:59:06 -04:00
Nikita Popov fe984c7cb5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Use wildcard for error message
2021-09-13 22:47:13 +02:00
Nikita Popov 5d702e33a2 Use wildcard for error message
This differs depending on build type.
2021-09-13 22:46:26 +02:00
Nikita Popov ba03c5fb4c Try to fix test 2021-09-13 21:07:46 +02:00
Dmitry Stogov 6d1a2b3aed Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Properly check if BIND_STATIC may throw
2021-09-13 21:59:47 +03:00
Dmitry Stogov ebd1a0a656 Properly check if BIND_STATIC may throw 2021-09-13 21:57:26 +03:00
Nikita Popov 8c601edada Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  BIND_STATIC may throw
2021-09-13 17:25:13 +02:00
Nikita Popov b610dce079 BIND_STATIC may throw
The evaluation of the initializer may throw. This could be refined
by checking whether the initializer is a constant AST. For now
just fix the miscompile.
2021-09-13 17:23:57 +02:00
Nikita Popov 133afe8591 Fix JIT call chain check without call opcode
The do_fcall opcode may have been optimized away if an opcode like
exit is present in the arguments. In that case the opcode scan
would go past the end of the op array.
2021-09-13 16:48:38 +02:00
Bob Weinand a8f06346ad Merge remote-tracking branch 'origin/PHP-8.0' into PHP-8.1 2021-09-13 16:15:55 +02:00
Bob Weinand 12b0f1b7cc Fix #81435 Observer current_observed_frame may point to an old (overwritten) frame
Ensure current_observed_frame always points to an actually observed frame.
This solution has a caveat of being O(stack size), with the worst case occurring if there are a lot of frames between the current and previous observed frames.
An O(1) solution would require keeping track of the previous observed frame, which would require some additional frame attached metadata, which is best not attempted in an already released version.
2021-09-13 15:58:58 +02:00
Nikita Popov 86d470f3e0 Reset CE cache slots on opcache reset
Permanent opcache interned strings could have ce_cache pointing to
non-permanent map_ptr slots. On reset, those would be left dangling.
Clear any non-permanent ce_cache slots when the interned string
state is reset.

This was fun to debug...
2021-09-13 15:20:34 +02:00
Remi Collet b3646440b1 Don't rely on libgd unused constants 2021-09-13 14:48:13 +02:00
Christoph M. Becker 311b1de649 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-09-13 14:38:37 +02:00
Christoph M. Becker 12e79ddae4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-09-13 14:35:49 +02:00
Christoph M. Becker a2471383fe Fix #81424: PCRE2 10.35 JIT performance regression
We backport the respective upstream fix[1] to our bundled pcre2lib.

[1] <https://github.com/PhilipHazel/pcre2/commit/dc5f96663597572f694147aeec3525003c351123>

Closes GH-7484.
2021-09-13 14:34:13 +02:00
Christoph M. Becker 9ffa3f9ba3 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
2021-09-13 12:14:32 +02:00
Christoph M. Becker 6fbdf69628 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
2021-09-13 12:13:09 +02:00
Viktor 424c265478 Fix #81433: DOMElement::setIdAttribute() called twice may remove ID
We must only remove the attribute id, if the user requested that.

Closes GH-7482.
2021-09-13 12:11:36 +02:00
Nikita Popov 9042c7aac6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Handle undef value in assign_dim jit
2021-09-13 11:10:03 +02:00
Nikita Popov e7663785a7 Handle undef value in assign_dim jit
We should report the undefined variable here and convert it to
null. Passing on undef is particularly insidious here, because
a write_dimension handler may insert it into a hash table
(observed with WeakMap).
2021-09-13 11:09:00 +02:00
Dmitry Stogov 971142a12a Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: Fixed exit from CALL VM with GCC Global Register Variables
2021-09-13 11:40:45 +03:00
Hao Sun cfb21e8dc1 JIT: Fixed exit from CALL VM with GCC Global Register Variables
PHP JIT supports three configurations: HYRBID, CALL with global register
variables feature(CALL+GRV for short), and CALL+noGRV.

CALL+GRV mode can be built with the following commands:

```
  php Zend/zend_vm_gen.php --with-vm-kind=CALL
  ./buildconf -f; ./configure; make
```

About 230 test cases failed for tracing JIT under CALL+GRV mode on both
x86 and arm64 machines.

For CALL+GRV mode, the condition to determine whether the execution of
an oparray is finished, is "opline == NULL". See function execute_ex()
around line "if (UNEXPECTED(!OPLINE)) {".

However, such cleanup operation is missing for the JIT wrapper
zend_jit_trace_counter_helper(), and the trace_halt stub function.

Tests:
1. test cases: all .phpt test cases under "Zend/tests/ tests/
ext/opcache/tests/jit/".
2. both JIT/x86 and JIT/arm64: function JIT, tracing JIT and tracing JIT
with "--repeat 3"
3. execution modes: NTS/ZTS, HYBRID/CALL+GRV/CALL+noGRV

In my local test, these test cases passed under all JIT configrations.
2021-09-13 11:35:12 +03: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
Jakub Zelenka 43f0141d74 Make OpenSSL tests less dependent on system config
It fixes dependencies on system config if running tests with OpenSSL 3.0
2021-09-12 20:30:02 +01:00
Kamil Tekiela d4ea11d0dc typo 2021-09-12 20:19:03 +01:00
Máté Kocsis ea9f943d33 Change gen-stub.php to gen_stub.php in help text 2021-09-12 17:09:56 +02:00
Máté Kocsis 73063db5c8 Fix documentation generation when legacy arginfo is generated
When legacy arginfo is generated, all the type info gets lost. Since this task is performed before any other additional functionalities of gen_stub.php (e.g. verification, method synopsis and class synopsis generation), these fail as they would require the missing type information.

The issue is fixed by deep cloning the file info objects (albeit only their affected properties), so that we use those for legacy arginfo generation, leaving the original ones untouched.
2021-09-12 11:42:22 +02:00
Remi Collet 6ee96f095a fix [-Wmaybe-uninitialized] build warnings 2021-09-10 15:57:56 +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 f86a963199 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Also make sure binary op operands can't be undef
2021-09-09 15:09:02 +02:00
Nikita Popov 8c3d33a054 Also make sure binary op operands can't be undef
Otherwise we will end up passing undef to xyz_function etc, which
is not permitted.
2021-09-09 15:08:08 +02:00
Nikita Popov b9a6ec2097 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Check whether expected types are present for compound op jit
2021-09-09 14:33:10 +02:00
Nikita Popov bac054dbf3 Check whether expected types are present for compound op jit
zend_jit_long_math_helper() implicitly assumes that the operands
MAY_BE_LONG (but can also have additional types). It will normally
only be called if this is guaranteed. However, for compound
array/object assignment ops this was not check. Generalize the
existing check for assign_op to apply to these as well.

Of course, we could also make the code support this correctly,
but I don't think it makes sense to JIT these if the type we're
specializing for is not present.

Closes GH-7481.
2021-09-09 14:32:14 +02:00
Dmitry Stogov 679bfb1522 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  JIT: fixed MUL+SEND optimization when MUL throws an exception
2021-09-08 17:57:21 +03:00
Dmitry Stogov 06275d940c JIT: fixed MUL+SEND optimization when MUL throws an exception 2021-09-08 17:53:23 +03:00
Nikita Popov f2bb739eeb Apply fix to ARM JIT as well
This is the same change as e22fb46127,
but for the ARM JIT implementation.
2021-09-08 15:46:35 +02:00
Nikita Popov 4bccf36973 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Save register before throwing undef var notice
2021-09-08 14:46:08 +02:00
Nikita Popov e22fb46127 Save register before throwing undef var notice
Otherwise we may clobber it while throwing the undef var notice.
This makes the implementation for assign_dim_op line up with
fetch_dim.
2021-09-08 14:45:49 +02:00
George Peter Banyard be2500f229 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix param name order for Phar::copy()
2021-09-08 12:32:58 +01:00
George Peter Banyard 0d0c9acafb Fix param name order for Phar::copy() 2021-09-08 12:31:09 +01:00