Commit Graph

2868 Commits

Author SHA1 Message Date
Nikita Popov
48622970fb Extract functions for file cache type serialization
This is already done in master.
2020-01-02 15:16:24 +01:00
Nikita Popov
3bc4159a19 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix file cache run_time_cache unserialization
  Update ZCSG(map_ptr_last) only if for_shm
2020-01-02 15:01:56 +01:00
Nikita Popov
36d5fbbd6b Fix file cache run_time_cache unserialization
If the script was serialized as file_cache_only (thus non-immutable)
and then gets unserialized into SHM, we need to allocate a new
run_time_cache slot and can't use the serialized arena pointer.
2020-01-02 14:56:39 +01:00
Nikita Popov
e576d342bb Update ZCSG(map_ptr_last) only if for_shm
Otherwise we may get a memory protection fault here. Updating of
ZCSG(map_ptr_last) is handled when loading from file cache to SHM.
2020-01-02 11:59:36 +01:00
Máté Kocsis
345703724c
Use RETURN_THROWS() during ZPP in most of the extensions
Except for some bigger ones: reflection, sodium, spl
2019-12-31 11:46:11 +01:00
Nikita Popov
3262c28d5c Merge branch 'PHP-7.4'
* PHP-7.4:
  Also propagate include exceptions in opcache
  Make url_stats in resolve_path quiet
2019-12-30 23:22:39 +01:00
Nikita Popov
22e9f9fe4d Also propagate include exceptions in opcache 2019-12-30 23:22:26 +01:00
Christoph M. Becker
e57b2b9465 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79040: Warning Opcode handlers are unusable due to ASLR
2019-12-30 15:18:25 +01:00
Christoph M. Becker
94063619a0 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79040: Warning Opcode handlers are unusable due to ASLR
2019-12-30 15:17:41 +01:00
Christoph M. Becker
0cecf83b26 Fix #79040: Warning Opcode handlers are unusable due to ASLR
We must not use the same shared memory OPcache instance for different
SAPIs, since their memory layout is different.  To avoid this, we add
the SAPI name (truncated to at most 20 characters) to the names of the
memory base file, the mutex and the file mapping.
2019-12-30 15:12:58 +01:00
Nikita Popov
6c6d36bb94 Fix SSA construction for ADD_ARRAY_ELEMENT in RC_INFERENCE mode
This was broken in cc29cbe80c.
2019-12-30 13:29:32 +01:00
Dmitry Stogov
7b69855bd0 Fixed type_info for new array element (it may be only NULL) 2019-12-26 16:32:45 +03:00
Dmitry Stogov
cc29cbe80c cleanup 2019-12-26 11:54:05 +03:00
Dmitry Stogov
e874811221 Build call graph before type inference 2019-12-24 16:15:24 +03:00
Dmitry Stogov
1e53769d82 Set opcode handler 2019-12-23 14:14:47 +03:00
Christoph M. Becker
dabc28d182 Fix #78880: Spelling error report
We fix the most often occuring typos according to a recent codespell
report[1] in tests, code comments and documentation.

[1] <https://fossies.org/linux/test/php-src-master-f8f48ce.191129.tar.gz/codespell.html>.
2019-12-21 11:58:00 +01:00
Máté Kocsis
d9eb97d745
Remove unnecessary FN type information from OPCache
GH-5029
2019-12-20 16:45:57 +01:00
Máté Kocsis
0e8070778e
Make get_defined_vars() always return an array
GH-5025
2019-12-20 14:31:57 +01:00
Máté Kocsis
f52f471a5e
Fix F1 type information in OPCache
Closes GH-5025
2019-12-20 14:31:30 +01:00
Nikita Popov
2bc0a6e97f Fix string offset signed int UB in jit as well 2019-12-20 12:11:07 +01:00
Máté Kocsis
bf645d6dc1
Remove unnecessary F0 type information from OPCache
Closes GH-5024
2019-12-20 12:03:08 +01:00
Nikita Popov
aadd5e69e0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78986
2019-12-18 11:41:11 +01:00
Nikita Popov
bd4fce4f6f Fixed bug #78986
Don't assume that handlers live in the arena, they may also be in
SHM.
2019-12-18 11:40:58 +01:00
Dmitry Stogov
b7e1eecd54 Avoid generation of "jmp" to next instruction 2019-12-17 15:42:02 +03:00
Dmitry Stogov
97bba4ffd6 Make "exception_handler_undef" stub to check EG(opline_before_exception) and undefine corresponnding result variable, if necessary.
This fixes few invalid "exception_handler_undef" usages.
2019-12-17 14:09:26 +03:00
Dmitry Stogov
546392b346 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78961 (erroneous optimization of re-assigned $GLOBALS)
2019-12-16 12:25:40 +03:00
Dmitry Stogov
6ef7e53c1b Fixed bug #78961 (erroneous optimization of re-assigned $GLOBALS) 2019-12-16 12:24:47 +03:00
Nikita Popov
a40a69fdd0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Introduce extra counter to avoid RTD key collisions
2019-12-13 11:05:41 +01:00
Nikita Popov
0f2cdbf214 Introduce extra counter to avoid RTD key collisions
Also generate a fatal error if a collision occurs in zend_compile.

This is not perfect, because collisions might still be introduced
via opcache, if one file is included multiple times during a request,
invalidate in the meantime and recompiled by different processes.

This still needs to be addressed, but this patch fixes the much
more common case of collisions occuring when opcache is not used.

Fixes bug #78903.
2019-12-13 11:04:44 +01:00
Nikita Popov
d56768817b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78950: Preloading trait method with static variables
2019-12-12 11:52:51 +01:00
Nikita Popov
be89a5c7f1 Fixed bug #78950: Preloading trait method with static variables
We need to make sure that trait methods with static variables
allocate a separate MAP slot for the static variables pointer,
rather than working in-place.
2019-12-12 11:52:43 +01:00
Nikita Popov
cf9362195b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix handling of non-final loop var free in sccp
2019-12-12 09:40:54 +01:00
Nikita Popov
2d03b638dc Fix handling of non-final loop var free in sccp
We only need to preserve the FE_FREE that marks the end of the
loop range. Skip FE_FREEs with the FREE_ON_RETURN flag.
2019-12-12 09:39:52 +01:00
Tyson Andre
1695d3ed07 Add funcinfo for spl global functions
This assumes that `iterator_*` will now always throw or abort on failure.

Also, move #include _arginfo.h directive to the top of the file - virtually all
other files put it there, and developers may base code on basic_functions.c.

Closes GH-4968
2019-12-11 18:17:04 -05:00
Dmitry Stogov
ee45dbab37 Merge branch 'PHP-7.4'
* PHP-7.4:
  Addirional fix for bug #78918
2019-12-11 12:29:10 +03:00
Dmitry Stogov
3280209c03 Addirional fix for bug #78918 2019-12-11 12:21:49 +03:00
Dmitry Stogov
8fb3ef6e37 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78937 (Preloading unlinkable anonymous class can segfault)
2019-12-11 00:47:15 +03:00
Dmitry Stogov
20ef51db22 Fixed bug #78937 (Preloading unlinkable anonymous class can segfault) 2019-12-11 00:46:30 +03:00
Dmitry Stogov
764c8159b7 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix error message
2019-12-10 22:17:42 +03:00
Dmitry Stogov
518a8f89c1 Fix error message 2019-12-10 22:17:10 +03:00
Nikita Popov
c2d92ad971 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix incorrect zend_try usage
2019-12-10 15:22:46 +01:00
Nikita Popov
5ddcacac2e Fix incorrect zend_try usage 2019-12-10 15:22:31 +01:00
Nikita Popov
fa18c115be Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix release build failure
2019-12-10 13:53:19 +01:00
Nikita Popov
d6f86caa11 Fix release build failure
GCC complained about potentially uninitialized __orig_bailout,
even though the variable has an initializer. This warning was
quite persistent, I was only able to avoid it by using a separate
function.

Am I missing something?
2019-12-10 13:51:09 +01:00
Christoph M. Becker
f2dbe4297b Merge branch 'PHP-7.4'
* PHP-7.4:
  Improve error message
2019-12-10 13:20:55 +01:00
Christoph M. Becker
9e22c3d4d9 Improve error message
Formerly, the error message was like:

| Can't preload unlinked class MyException: Internal parent (Windows
| only limitation)Exception

Now it's like:

| Can't preload unlinked class MyException: Windows can't link to
| internal parent Exception
2019-12-10 13:19:58 +01:00
Nikita Popov
5cdea8d5e8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add support for class_alias to preloading
  Fixed bug #78935: Check that all linked classes can be preloaded
2019-12-10 13:12:29 +01:00
Nikita Popov
baf3a9133b Add support for class_alias to preloading
Related to bug #78918.
2019-12-10 13:06:36 +01:00
Nikita Popov
3f86adb0ef Fixed bug #78935: Check that all linked classes can be preloaded
During preloading, check that all classes that have been included
as part of the preload script itself (rather than through opcache_compile_file)
can actually be preloaded, i.e. satisfy Windows restrictions, have
resolved initializers and resolved property types. When resolving
initializers and property types, also autoload additional classes.
Because of this, the resolution runs in a loop.
2019-12-10 13:05:48 +01:00
Nikita Popov
ea4bb58889 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix merge mistake
2019-12-10 09:04:01 +01:00
Nikita Popov
4313659bb9 Fix merge mistake 2019-12-10 09:03:44 +01:00
Nikita Popov
c124d202e2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix DCE with FE_FETCH
2019-12-10 09:01:55 +01:00
Nikita Popov
7e028a41e2 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix DCE with FE_FETCH
2019-12-10 09:01:18 +01:00
Nikita Popov
87691e74e5 Fix DCE with FE_FETCH
For now, don't treat FE_FETCH op2 as no-val use. See GH-4982.
2019-12-10 09:00:09 +01:00
Máté Kocsis
9563449d8b
Add stubs for another batch of standard functions 2019-12-09 19:47:08 +01:00
Máté Kocsis
6f9248359e
Throw an exception when an invalid comparison operator is passed to version_compare() 2019-12-09 19:44:01 +01:00
Dmitry Stogov
ebf35cc8e8 Fixed operation with result in CPU register 2019-12-06 17:16:46 +03:00
Dmitry Stogov
990b556761 Use cheaper code for overflow +/-1 2019-12-06 14:04:58 +03:00
Nikita Popov
e0a8c7a8d0 Remove CV limitation when determining value from type in SCCP
As far as I can determine, this is no longer a problem: We will
not try to remove the defining instructions (this is only done if
the value is known by SCCP itself) and we also only determine
non-refcounted values in this way, so it is not a problem if the
FREE is omitted.
2019-12-05 15:26:16 +01:00
Nikita Popov
9e403d65d8 Add DCE support for ARRAY_KEY_EXISTS 2019-12-05 14:55:22 +01:00
Máté Kocsis
29ef07728e
Remove magic quotes legacy 2019-12-05 13:15:54 +01:00
Máté Kocsis
144b41ce88
Remove money_format() function 2019-12-05 13:15:54 +01:00
Máté Kocsis
64468d1e3b
Remove convert_cyr_string() function 2019-12-05 13:15:54 +01:00
Máté Kocsis
b63c625260
Remove hebrevc() function 2019-12-05 13:15:54 +01:00
Tyson Andre
616ec2dd98 Update/fix remaining opcache zend_func_info.c signatures
See UPGRADING:

> . The GD extension now uses objects as the underlying data structure for
>   images, rather than resources. These objects are completely opaque, i.e.
>   they don't have any methods.

Remove types which are no longer in Reflection due to throwing instead of
emitting warnings.
Remove entries where reference counts are 0 and types are duplicated.

Closes GH-4967.
2019-12-05 07:29:03 +01:00
Tyson Andre
96d2b69653 Remove opcache signatures duplicating reflection
None of these are refcounted.
2019-12-04 09:50:24 -05:00
Tyson Andre
1142f0c4a5 Make more opcache signatures consistent with reflection 2019-12-04 09:40:42 -05:00
Nikita Popov
7b34e30b9a Merge branch 'PHP-7.4'
* PHP-7.4:
  Preload: Better reason message for internal parents on windows
2019-12-04 09:53:08 +01:00
Nikita Popov
7cbf31a3c7 Preload: Better reason message for internal parents on windows
Related to bug #78881.
2019-12-04 09:52:40 +01:00
Tyson Andre
0dbc24c3fa Fix other incorrect opcache types
Closes GH-4959.
2019-12-04 07:40:25 +01:00
Tyson Andre
5624d2eb00 Make some opcache types consistent with reflection information
Remove functions such as filter_id() where reference counts and types are
identical to what's in opcache.

Remove null types from zend_func_info.c that aren't in Reflection
(php would throw now)

Fix the Reflection type information for assert_options()

    php > assert_options(ASSERT_CALLBACK, static function() {});
    php > var_export(assert_options(ASSERT_CALLBACK));
    Closure::__set_state(array(
    ))

Closes GH-4958.
2019-12-04 07:31:06 +01:00
Nikita Popov
8dead642fe Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix print_r return types in opcache
2019-12-04 07:17:18 +01:00
Nikita Popov
39b08ba99c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix print_r return types in opcache
2019-12-04 07:16:56 +01:00
Tyson Andre
c8e9aa854c Fix print_r return types in opcache
https://www.php.net/print_r

> When the return parameter is TRUE, this function will return a string.
> Otherwise, the return value is TRUE.
2019-12-04 07:16:32 +01:00
Adam Saponara
b35acd30f2 Fix misleading error message in ZendAccelerator.c.
Currently this error emits something like...

`Error Cannot kill process 12345: Success!`

...due to calling `time` before `strerror` which clears `errno`. This
patch adds an error log immediately after both `kill` calls which gives
us better indication of what exactly failed.
2019-12-02 10:06:32 +01:00
Lucas Martín
c0e049656c Fix typo in xmm15 register 2019-12-01 12:28:19 +01:00
Dmitry Stogov
f8f48ce8f5 Refactor JIT to reduce back-end dependency from SSA representation.
This commit shouldn't change JIT behavior, but it adds asserts, that may catch wrong-cases occasionally passed before.
2019-11-29 19:07:17 +03:00
Dmitry Stogov
3360d05f30 Don't keep QM_ASSIGN with IS_UNUSED result 2019-11-29 17:43:36 +03:00
Dmitry Stogov
b7241adf5e typos 2019-11-28 13:23:17 +03:00
Dmitry Stogov
36175b3c3d Fixed wrong parameteris order 2019-11-27 16:48:01 +03:00
Dmitry Stogov
40ef3196e0 Fixed register allocation 2019-11-27 16:26:43 +03:00
Dmitry Stogov
249e9a63e8 Fixed JIT for LONG->DOUBLE conversion when optimizer disabled 2019-11-27 14:31:24 +03:00
Dmitry Stogov
b046a8f7f8 Fixed incorrect JIT compilation 2019-11-26 16:45:19 +03:00
avkarenow
182f98a194 Open opcache.error_log with 'a' flag
When opcache.error_log is set to log to file the read flag is not needed and used.
2019-11-26 09:29:27 +03:00
Tyson Andre
f7c44ef2a0 Make opcache infer array_key_exists is non-null bool
array_key_exists now throws a TypeError instead of returning null
for invalid arguments after 14bdb0cfc7
2019-11-20 00:11:51 +03:00
Dmitry Stogov
8bf663d3b2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix $x = (bool)$x; for undefined with opcache
2019-11-18 11:29:38 +03:00
Dmitry Stogov
be6fb13873 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix $x = (bool)$x; for undefined with opcache
2019-11-18 11:27:43 +03:00
Dmitry Stogov
e72e3370c6 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix $x = (bool)$x; for undefined with opcache
2019-11-18 11:26:30 +03:00
Tyson Andre
a2c41c0ea6 Fix $x = (bool)$x; for undefined with opcache
And `$x = !$x`

Noticed while working on GH-4912

The included test would not emit undefined variable errors in php 8.0
with opcache enabled. The command used:

```
php -d zend_extension=opcache.so --no-php-ini -d error_reporting=E_ALL \
    -d opcache.file_cache= -d opcache.enable_cli=1  test.php
```
2019-11-18 11:24:03 +03:00
Nikita Popov
bb41a1b7e7 Fix str_pad rc info
This fixes at least part of bug #78811.
2019-11-15 12:37:24 +01:00
Christoph M. Becker
39d04f15f8 Fix ASLR related invalid opline handler issues
Opcache stores `opline->handler`s in shared memory.  These pointers are
invalid, if the main PHP DLL is loaded at another base address due to
ASLR.  We therefore store the address of `execute_ex` in the mmap base
file, and check on startup whether it matches its current address.  If
not, we fall back on the file cache if enabled, and bail out otherwise.

This still does not address cases where the opline handler is located
inside of another DLL (e.g. for some profilers, debuggers), but there
seems to be no general solution for now.

(cherry picked from commit 8ba10b8fbc)
2019-11-15 09:46:58 +01:00
Dmitry Stogov
36afe4e39e Optimize $x === null into is_null($x) 2019-11-12 13:49:55 +03:00
Dmitry Stogov
bd45881014 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed wrong constant usage
2019-11-12 13:00:37 +03:00
Dmitry Stogov
49fcbb4810 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed wrong constant usage
2019-11-12 13:00:27 +03:00
Dmitry Stogov
9083e178f6 Fixed wrong constant usage 2019-11-12 12:59:50 +03:00
Dmitry Stogov
d94c27dcca Fixed JIT for TYPE_CHECK opcode (exception handling in case of undefined argument) 2019-11-12 10:42:29 +03:00
Máté Kocsis
27e83d0fb8
Add union return types for function stubs 2019-11-11 14:54:55 +01:00
Nikita Popov
999e32b65a Implement union types
According to RFC: https://wiki.php.net/rfc/union_types_v2

The type representation now makes use of both the pointer payload
and the type mask at the same time. Additionall, zend_type_list is
introduced as a new kind of pointer payload, which is used to store
multiple class types. Each of the class types is a tagged pointer,
which may be either a class name or class entry. The latter is only
used for typed properties, while arguments/returns will instead use
cache slots. A type list can contain a mix of both names and CEs at
the same time, as not all classes may be resolvable.

One thing this is missing is support for union types in arginfo
and stubs, which I want to handle separately.

I've also dropped the special object code from the JIT implementation
for now -- I plan to add this back in a different form at a later time.
For now I did not want to include non-trivial JIT changes together
with large functional changes.

Another possible piece of follow-up work is to implement "iterable"
as an internal alias for "array|Traversable". I believe this will
eliminate quite a few special-cases that had to be implemented.

Closes GH-4838.
2019-11-08 15:15:48 +01:00
Nikita Popov
ac4e0f0852 Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This
is in preparation for union types, where we will be using both at
the same time.

To avoid increasing the size of arginfo structures, the
pass_by_reference and is_variadic fields are now stored as part of
the type_mask (8-bit are reserved for custom use).

Different types of pointer payloads are distinguished based on bits
in the type_mask.
2019-11-08 15:15:48 +01:00
Fabien Villepinte
a555cc0b3d Clean DONE tags from tests
Remove most of the `===DONE===` tags and its variations.
Keep `===DONE===` if the test output otherwise becomes empty.

Closes GH-4872.
2019-11-07 21:31:47 +01:00