Commit Graph

16632 Commits

Author SHA1 Message Date
Nikita Popov
de5b42219c Avoid writing zend_vm_opcodes.h if it did not change
Now that we track header changes, a change to zend_vm_opcodes.h
requires rebuilding essentially the whole tree. In most cases,
changes to zend_vm_def.h don't actually result in any header
changes though.

Avoid touching the file by first checking whether the to be written
contents are actually the same.
2021-02-17 17:18:57 +01:00
Alex Erohin
cbfdc1fd54 Coding style tweaks for zend_vm_gen.php
- fixed array style for $vm_kind_name and $op_types
- deleted unnecessary else statement for is_hot_helper function
- fixed concatenation style
- fixed style of using whitespace between "(" and switch/foreach - replaced !is_null with "!=="

Closes GH-6704.
2021-02-17 17:05:34 +01:00
Máté Kocsis
803779e84b
Add support for generating properties with union type of multiple classes
Closes GH-6701
2021-02-16 15:50:13 +01:00
Nikita Popov
8b4ae72efb Fix unused variable warning 2021-02-16 14:24:58 +01:00
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Nikita Popov
1f04f162a6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80723
2021-02-16 12:34:00 +01:00
Nikita Popov
cb9785add1 Fixed bug #80723
This fixes the issue just for the Socket class. Presumably we'll
want to do the same for other "resource" objects.
2021-02-16 12:33:50 +01:00
Dmitry Stogov
f8cf7152a9 Microoptimization of STRLEN and IN_ARRAY opcodes (based on https://github.com/php/php-src/pull/4981) 2021-02-16 14:11:47 +03:00
Nikita Popov
353f7ffb6b Delref only after successful allocation
Otherwise we may have inconsistent refcounts after OOM.

I expect this problem is much more prevalent, but this at least
fixes some string/array separation cases.

Fixes oss-fuzz #30999.
2021-02-16 10:01:46 +01:00
Nikita Popov
e70f1b0488 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix symtable cache being used while cleaning symtable
2021-02-15 14:59:07 +01:00
Nikita Popov
882862563a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix symtable cache being used while cleaning symtable
2021-02-15 14:58:59 +01:00
Nikita Popov
7b7d99839c Fix symtable cache being used while cleaning symtable
We need to first clean the symtable and then check whether a cache
slot is available for it. Otherwise, it may happen that a destructor
runs while cleaning the table and uses up all the remaining slots
in the cache.

This is particularly insidious because once we overflow the cache,
the first pointer we modify is symtable_cache_ptr, making it hard
to understand what happened after the fact.

Fixes oss-fuzz #30815.
2021-02-15 14:58:38 +01:00
Nikita Popov
643a727c37 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix assertion failure in cufa optimization with named args
2021-02-15 12:43:50 +01:00
Nikita Popov
c70220205e Fix assertion failure in cufa optimization with named args
Fixes oss-fuzz#30764.
2021-02-15 12:43:31 +01:00
David CARLIER
2b93ae601a Use VM_MAKE_TAG for macos memory tag
In case Apple changes the meaning of the macro in the future.

Closes GH-6687.
2021-02-15 09:48:04 +01:00
Máté Kocsis
6ce70447ac
Generate zend class entries based on stubs
Closes GH-6685
2021-02-14 23:18:28 +01:00
Tyson Andre
8ffc20ace6 Optimize Traversable unpacking in zend_vm_def.h
The C compiler sees that a dynamic function is being called, so it cannot infer
that iter->funcs has not changed.

This results in more assembly instructions and slightly more time to execute that code
path.

Unpacking traversables to arrays(`ZEND_ADD_ARRAY_UNPACK`),
starting foreach loops (`ZEND_FE_FETCH*`), etc. are affected.

```
<?php
/*
 * Before: 1.576 seconds
 * After:  1.474 seconds
 */
function example() {
    $start = hrtime(true);
    $it = new SplFixedArray(1000);
    $total = 0;
    for ($i = 0; $i < 100000; $i++) {
        $total += count([...$it]);
    }
    $end = hrtime(true);
    printf("Elapsed: %.6f\n", ($end - $start) / 1_000_000_000);
}
example();
```
2021-02-13 09:34:48 -05:00
Nikita Popov
b10416a652 Deprecate passing null to non-nullable arg of internal function
This deprecates passing null to non-nullable scale arguments of
internal functions, with the eventual goal of making the behavior
consistent with userland functions, where null is never accepted
for non-nullable arguments.

This change is expected to cause quite a lot of fallout. In most
cases, calling code should be adjusted to avoid passing null. In
some cases, PHP should be adjusted to make some function arguments
nullable. I have already fixed a number of functions before landing
this, but feel free to file a bug if you encounter a function that
doesn't accept null, but probably should. (The rule of thumb for
this to be applicable is that the function must have special behavior
for 0 or "", which is distinct from the natural behavior of the
parameter.)

RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg

Closes GH-6475.
2021-02-11 21:46:13 +01:00
Tyson Andre
808da26a33 Fix typo in warnings_during_sccp
Should be capture_warnings_during_sccp

Related to 4c088c5da7
2021-02-11 08:23:01 -05:00
Nikita Popov
4c088c5da7 Handle warnings during sccp function evaluation
Some upcoming changes like https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
will make it somewhat inconvenient to determine whether a given
function invocation will generate a diagnostic. Rather than trying
to exclude this in advance, call the function with diagnostics
suppressed, and check whether anything was thrown.

This adds a new EG flag that is kept specific to the SCCP use-case.
This does not use the error_cb hook as it is a (non-TLS) global,
and doesn't fully suppress error handling besides.

Test this by removing the in advance checks for implode and array_flip.
2021-02-11 12:36:35 +01:00
Nikita Popov
4224b704b1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Update func info after password_get_info() change
2021-02-11 11:44:36 +01:00
Nikita Popov
e396506cd6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't throw additional Error in require_once if exception already thrown
2021-02-11 09:42:05 +01:00
Nikita Popov
d80d918547 Don't throw additional Error in require_once if exception already thrown
As pointed out in comments on bug #66216.
2021-02-11 09:41:19 +01:00
Dmitry Stogov
e1fda1025c Link unbound simple classes (without parent/intefaces/traits) in first place. 2021-02-10 23:57:50 +03:00
Dmitry Stogov
ef51648185 Use zend_type.ce_cache__ptr for caching class resulution during argument/result type checks 2021-02-10 18:00:00 +03:00
Máté Kocsis
45fa7596dc
Add missing classes to stubs 2021-02-09 22:38:06 +01:00
Dmitry Stogov
c098952d72 Use IS_ALIAS_PTR to make distinct between aliasses and real classes 2021-02-10 00:00:55 +03:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Nikita Popov
9d54609a19 Merge branch 'PHP-8.0'
* PHP-8.0:
  Use E_ERROR to report arginfo/zpp mismatch
  Make NumberFormatter ctor $pattern nullable
  Make IntlDateFormatter ctor $pattern nullable
2021-02-09 14:37:41 +01:00
Nikita Popov
d4aff25473 Use E_ERROR to report arginfo/zpp mismatch
When E_CORE_ERROR is used, we don't get correct file/line information.
2021-02-09 14:36:44 +01:00
Máté Kocsis
8c14675217
Remove a few more unnecessary @generate-function-entries annotations 2021-02-09 13:37:54 +01:00
Nikita Popov
27cd7a11cb Add support for string keys in array unpacking
This adds support for:

    $array1 = ['a' => 1, 'b' => 2];
    $array2 = ['b' => 3, 'c' => 4];
    $array = [...$array1, ...$array2];
    // => ['a' => 1, 'b' => 3, 'c' => 4]

RFC: https://wiki.php.net/rfc/array_unpacking_string_keys

Closes GH-6584.
2021-02-09 10:04:27 +01:00
Levi Morrison
32dd853624 Document .dtor_obj and .free_obj
Closes GH-6656.

Co-authored-by: Nikita Popov <nikic@php.net>
2021-02-01 10:53:36 +01:00
Nikita Popov
83be073abe Move optimizer into core
This only moves the files, adjusts the build system, exports APIs
and does minor fixups to make sure the code builds.

This does not yet try to make the optimizer usable independently
of opcache.

Closes GH-6642.
2021-01-28 10:38:25 +01:00
Nikita Popov
ac561f2c25 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix stub for Serializable::serialize()
2021-01-28 10:15:45 +01:00
Michael Voříšek
27eb81604b Fix stub for Serializable::serialize()
This method may also return null.
2021-01-28 10:15:07 +01:00
Nikita Popov
6971c720b0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Observe fake closures
2021-01-28 10:05:51 +01:00
Sammy Kaye Powers
17142eab22 Observe fake closures
Closes GH-6607.
2021-01-28 10:03:41 +01:00
Dmitry Stogov
1d2fd57c99 Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow observer handlers disabling optimization in RETURN opcode handler, that may cause loss value of returned local variable.
2021-01-26 19:25:50 +03:00
Dmitry Stogov
b529d02d24 Allow observer handlers disabling optimization in RETURN opcode handler, that may cause loss value of returned local variable. 2021-01-26 19:23:13 +03:00
Dmitry Stogov
9948142e50 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip dummy frames allocated on CPU stack of zend_call_function(). (Usage of "current_observed_frame" varible looks unsafe to me).
2021-01-26 18:44:56 +03:00
Dmitry Stogov
094e1a8b2d Skip dummy frames allocated on CPU stack of zend_call_function().
(Usage of "current_observed_frame" varible looks unsafe to me).
2021-01-26 18:41:26 +03:00
Nikita Popov
b3189e7dad Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix VAR return type verification
2021-01-26 15:18:04 +01:00
Nikita Popov
a2dcd44272 Fix VAR return type verification
We should also set retval_ref when de-indirecting. Otherwise the
retval_ref != retval_ptr comparison below may incorrect assume
that we're returning a reference.

I don't have a reliable reproducer for this issue, but it sometimes
appears in certain configurations in arrow_functions/007.phpt in
conjunction with other changes.
2021-01-26 15:15:18 +01:00
Nikita Popov
776726da03 Add missing resource key warning for unset()
It was present on other operations, including isset(), but was
missing for unset().
2021-01-26 12:51:02 +01:00
Máté Kocsis
1954e59758
Add support for generating class entries from stubs
Closes GH-6289

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-01-26 11:50:36 +01:00
Nikita Popov
6bc97b5921 Merge branch 'PHP-8.0'
* PHP-8.0:
  Improve switch continue warning
2021-01-25 16:18:11 +01:00
Nikita Popov
18507853cb Improve switch continue warning
Don't suggest "continue N+1" if there is no wrapping loop. The
resulting code would be illegal.
2021-01-25 16:17:50 +01:00
Nikita Popov
cc3e03c512 Fix parsing of semi-reserved tokens at offset > 4 GB
To avoid increasing the size of parser stack elements by storing
size_t offset and length, this instead only stores the start
offset (or rather pointer now) and determines the length of the
identifier in zend_lex_tstring.
2021-01-25 14:37:36 +01:00
Nikita Popov
321bd6b1f4 Improve error message for leading comma in keyed list assignment
Print "Cannot use empty array entries in keyed array assignment"
instead of "Cannot mix keyed and unkeyed array entries in assignments"
for a leading comma.
2021-01-25 11:13:37 +01:00
Nikita Popov
3370b5fd87 Accept zend_string in zend_prepare_string_for_scanning 2021-01-21 10:31:32 +01:00
Dusk
13c430b1db Add array_is_list(array $array) function
This function tests if an array contains only sequential integer keys. While
list isn't an official type, this usage is consistent with the community usage
of "list" as an annotation type, cf.
https://psalm.dev/docs/annotating_code/type_syntax/array_types/#lists

Rebased and modified version of #4886

- Use .stub.php files
- Add opcache constant evaluation when argument is a constant
- Change from is_list(mixed $value) to array_is_list(array $array)

RFC: https://wiki.php.net/rfc/is_list

Co-Authored-By: Tyson Andre <tysonandre775@hotmail.com>
Co-Authored-By: Dusk <dusk@woofle.net>

Closes GH-6070
2021-01-20 18:53:48 -05:00
Gabriel Caruso
34f0f60db5
Next is 8.0.3 2021-01-19 13:00:48 -03:00
Nikita Popov
dbe5725ff3 Rename zend-test to zend_test
The extension name should match the name of the ext/ directory,
otherwise it will not get picked up by run-tests. It would be possible
to remap this in run-tests, but I think it's better to rename the
extension to follow the standard format. Other extensions also
use underscore instead of hyphen (e.g. pdo_mysql and not pdo-mysql).
Of course, the ./configure option remains hyphenated.

Closes GH-6613.
2021-01-19 15:28:15 +01:00
Dmitry Stogov
b3bbb8fe3b Mark classes cached by opcache by ZEND_ACC_CACHED flag and prevent useless copying and desrpoying of immutable data. 2021-01-19 11:55:09 +03:00
Dmitry Stogov
c195fcd678 Avoid modification of trait info 2021-01-19 11:54:01 +03:00
sj-i
6a1e74eb32 Delete an outdated comment for read_property and read_dimension. [ci skip]
The comment is outdated as of PHP7.
For example, in the current code, zend_assign_op_overloaded_property() expects the refcount of the returned value from read_property to be greater than 0 when the returned value is a refcounted, to call zval_ptr_dtor() later.

History:
- The same description was originally written in a commit in 2004 alongside the write side. c8c0e97982
- One requested to put the description in somewhere. https://externals.io/message/7789
- Then it was added as a comment in zend_object_handler.h . 7d3215d333
- At the time the comment was written, there were at least three places where the code actually set the reference count to 0 in read_properties.
	- 7d3215d333/ext/dom/php_dom.c (L229)
	- 7d3215d333/ext/mysqli/mysqli.c (L190)
	- 7d3215d333/ext/simplexml/simplexml.c (L245)
- All three of the above were removed during the development of PHP 7.
	- 2f0a758fbb
	- 2402d6cbbc
	- a975c7e0fe
- In the current code, even when they generate and return a refcounted value, its refcount would be 1.

Closes GH-6618.
2021-01-19 09:49:39 +01:00
Nikita Popov
9862296d46 Fix $GLOBALS[] in isset and unset
I've previously addressed the case of assignments, but the same
issue exists for isset and unset.

Fixes oss-fuzz #29699.
2021-01-18 10:31:38 +01:00
Nikita Popov
21562aa98d Check for append to $GLOBALS
Fixes oss-fuzz #29389.
2021-01-15 16:58:31 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
16cf1b915d compare_function() returns zend_result 2021-01-15 11:51:28 +01:00
Nikita Popov
058756b3bb Remove the convert_to_long_base function
This function is unused in php-src, and has somewhat dubious
semantics, especially since we switched convert_to_long to not
use strtol for the base 10 case.

If you want to convert strings from a different base, use
ZEND_STRTOL directly.
2021-01-15 10:43:26 +01:00
Nikita Popov
b429228420 Remove zend_locale_sprintf_double()
This function is unused, and also not particularly useful now that
PHP no longer prints doubles in a locale-sensitive way unless
someone really goes out of their way to force it.
2021-01-14 12:13:34 +01:00
Nikita Popov
422d1665a2 Make convert_to_*_ex simple aliases of convert_to_*
Historically, the _ex variants separated the zval first, if a
conversion was necessary. This distinction no longer makes sense
since PHP 7.

The only difference that was still left is that _ex checked whether
the type is the same first, but the usage of these macros did not
actually distinguish on whether such an inlined check is valuable
or not in a given context.

Also drop the unused convert_to_explicit_type macros.
2021-01-14 12:11:11 +01:00
Nikita Popov
1b2aba285d Remove Z_PARAM separate params where they don't make sense
Separation can only possibly make sense for array parameters
(or something that can contain arrays, like zval parameters). It
never makes sense to separate a bool.

The deref parameters are also of dubious utility, but leaving them
for now.
2021-01-14 11:58:08 +01:00
Nikita Popov
ec58a6f1b0 Remove SEPARATE_ZVAL_IF_NOT_REF() macro
This macro hasn't made sense since PHP 7. The correct pattern to
use is ZVAL_DEREF + SEPARATE_ZVAL_NOREF.
2021-01-14 11:08:44 +01:00
Nikita Popov
aa51785889 Remove SEPARATE_ARG_IF_REF macro
The name doesn't correspond to what it does at all, and all the
existing usages appear to be unnecessary.

Usage of this macro can be replaced by ZVAL_DEREF + Z_TRY_ADDREF_P.
2021-01-14 10:53:56 +01:00
Nikita Popov
cc4a247a5e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80617: Type narrowing warning in ZEND_TYPE_INIT_CODE
2021-01-14 10:09:16 +01:00
Nikita Popov
880bf62224 Fixed bug #80617: Type narrowing warning in ZEND_TYPE_INIT_CODE 2021-01-14 10:08:22 +01:00
Nikita Popov
ad5ae0634d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80596: Fix anonymous class union typehint errors
2021-01-14 10:04:47 +01:00
Daniil Gentili
f9fbba41b6 Fixed bug #80596: Fix anonymous class union typehint errors
Cut off part after null byte when resolving the class name, to
avoid cutting off a larger part lateron.

Closes GH-6601.
2021-01-14 10:04:27 +01:00
sj-i
37b94ac38a Fix #51758: delete an outdated comment from zend_object_handler.h [ci skip]
The same description was originally written in a commit in 2004 which fixes a bug in the pre-released simplexml.
c8c0e97982

One requested to put the description in somewhere.
https://externals.io/message/7789

Then it was added as a comment in zend_object_handler.h .
7d3215d333

At the time of the comment written, the refcount of RHS was simply incremented before calling the write handler in the process of ZEND_ASSIGN_OBJ.
c8c0e97982/Zend/zend_execute.c (L407)

The refcount of a zval may be 0 or 1 if the write handler is called from zend_API in that era.
c8c0e97982/Zend/zend_API.c (L1058-L1170)

The original fix in simplexml was removed in 2018, because scalar types don't have reference counter anymore as of PHP7.
f7f790fcc9
4a475a4976

It seems that the original intent of this prescription was preventing unintended modification to the RHS and values which share the memory location with the RHS in assignments.

In the first place, it is not usual trying to change the RHS in a write handler, IMHO. I don't think the description makes sense in the current situation about handling of refcount, so I simply delete the whole sentences.

Because write_dimension has no return value, the mentioning about the return value is moved to the comment for write_property only.

Closes GH-6597.
2021-01-14 09:50:00 +01:00
Dmitry Stogov
1a44599dee Always use CG(arena) for unin type lists 2021-01-12 16:33:38 +03:00
Nikita Popov
45a4d07dd0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Add support for union types for internal functions
2021-01-12 10:15:13 +01:00
Nikita Popov
973138f39d Add support for union types for internal functions
This closes the last hole in the supported types for internal
function arginfo types. It's now possible to represent unions of
multiple classes. This is done by storing them as TypeA|TypeB and
PHP will then convert this into an appropriate union type list.

Closes GH-6581.
2021-01-12 10:14:41 +01:00
Dmitry Stogov
9fc11762e5 PHP array cannot refer to EG(symbol_table) any more. Replace corresponding checks by ZEND_ASSERT(). 2021-01-11 18:26:01 +03:00
Nikita Popov
22793884b6 Remove some INDIRECT handling in VM 2021-01-06 12:46:31 +01:00
Nikita Popov
3c68f38fda Restrict allowed usages of $GLOBALS
This restricts allowed usage of $GLOBALS, with the effect that
plain PHP arrays can no longer contain INDIRECT elements.

RFC: https://wiki.php.net/rfc/restrict_globals_usage

Closes GH-6487.
2021-01-06 12:46:24 +01:00
Nikita Popov
5c3a3dd2aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix infinite recursion in unlinked_instanceof
2021-01-05 13:04:00 +01:00
Nikita Popov
dd335359e9 Fix infinite recursion in unlinked_instanceof
I suspect this is only a partial fix for the issue, it's probably
possible to recurse through a more complex pathway as well.

Fixes oss-fuzz #28961.
2021-01-05 13:03:41 +01:00
Nikita Popov
0067c3ced1 Fix lexing of zero octal followed by whitespace
We'd call strtol starting at the whitespace, and strtol strips
whitespace...

Fixes oss-fuzz #29272.
2021-01-05 12:25:19 +01:00
George Peter Banyard
589bdf30b2 Implement Explicit octal notation for integers RFC
RFC: https://wiki.php.net/rfc/explicit_octal_notation

Add an extensive test suits for other variants of integer literals

Closes GH-6360
2021-01-04 21:09:23 +01:00
Tyson Andre
dfb9e03336 Use Z_PARAM_OBJ macros when zval isn't needed
In some cases, like spl_object_id, the code is simpler but equally efficient
after optimizations.

In other cases, like get_mangled_object_vars(), the compiler can't infer that
the object in the zval won't change.

Closes GH-6567
2021-01-02 16:10:14 -05:00
Nikita Popov
442fa318a0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80537
2020-12-21 10:23:42 +01:00
Nikita Popov
27e250880b Fix bug #80537
This is an unavoidable breaking change to both the type and
parameter name.

The assertion that was supposed to prevent this was overly lax
and accepted any object type for string parameters.
2020-12-21 10:21:50 +01:00
Levi Morrison
95a4e1ea3b Fix ubsan error on Mac
Fixes this error:
> Zend/zend_alloc.c:473:73: runtime error: left shift of 250 by 24 places cannot be represented in type 'int'
2020-12-16 21:24:31 -07:00
Nikita Popov
52435f94a3 Merge branch 'PHP-8.0'
* PHP-8.0:
  PDO MySQL: Use mysqlnd column names
2020-12-16 15:18:43 +01:00
Nikita Popov
205d209de9 PDO MySQL: Use mysqlnd column names
mysqlnd already creates interned zend_strings for us, so let's
make use of them.

This also required updating the PDO case changing code to work
with potentially shared strings. For the lowercasing, use the
optimized zend_string_tolower() implementation.
2020-12-16 15:17:13 +01:00
Nikita Popov
8bd5310a1e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80523
2020-12-16 10:20:57 +01:00
Nikita Popov
f6bd3dfdbc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #80523
2020-12-16 10:20:43 +01:00
Nikita Popov
118ff03335 Fix bug #80523
Don't truncate the file length to unsigned int...

I have no idea whether that fully fixes the problem because the
process gets OOM killed before finishing, but at least the
immediate parse error is gone now.
2020-12-16 10:20:20 +01:00
Gabriel Caruso
f1f78ac875
Next is 8.0.2 2020-12-15 10:30:55 -03:00
Nikita Popov
3642042629 Merge branch 'PHP-8.0'
* PHP-8.0:
  IBM i PASE doesn't support ITIMER_PROF
2020-12-15 10:15:52 +01:00
Nikita Popov
b6d043aae2 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  IBM i PASE doesn't support ITIMER_PROF
2020-12-15 10:15:47 +01:00
Calvin Buckley
54248b18fe IBM i PASE doesn't support ITIMER_PROF
Like Cygwin, this platform needs to use a real-time timer.

This was based on a patch by @kadler, but it didn't handle unsetting
the timer, so the timeout would continue to be active, triggering
`hard_timeout` unexpectedly. The patch is fixed to handle unsetting.

Closes GH-6503.
2020-12-15 10:15:28 +01:00
jellyNoone
c1e977f1bb Add more tests that document late static binding
Closes GH-6515.
2020-12-15 10:04:39 +01:00
twosee
a38aaf6cbd Merge branch 'PHP-8.0'
* PHP-8.0:
  EXTERN_C wrapping for GC buffer APIs
2020-12-10 17:16:08 +08:00
twosee
26c7b9402d EXTERN_C wrapping for GC buffer APIs
Closes GH-6502.
2020-12-10 17:15:19 +08:00
hgsgtk
6992c38ecc Fix typo 'variabled' in named_params/undef_var.phpt
Closes GH-6499.
2020-12-09 19:29:07 +01:00
Nikita Popov
174832902c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix removal of type source during unserialization
2020-12-04 12:57:37 +01:00
Nikita Popov
77325c4448 Fix removal of type source during unserialization
Missed a check for info in this code. Add it, and add an assertion
in type source removal to make it easier to catch this issue.

Fixes oss-fuzz #28208 and #28257.
2020-12-04 12:56:05 +01:00
Nikita Popov
2dcf71cbfd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80462
2020-12-02 10:19:42 +01:00
Nikita Popov
7a61984a2b Fixed bug #80462 2020-12-02 10:19:32 +01:00
Sara Golemon
1071d85764
Flesh out HashTable insertion APIs
Fills out the array/object-property insert helpers for zend_array, zend_object, and zend_reference.

This adds the following matrix of 18 APIs
add_next_index_T()
add_index_T()
add_assoc_T()
add_assoc_T_ex()
add_property_T()
add_property_T_ex()

Where T in array, object, reference

Converted internal callsites currently doing an explicit object wrap.
2020-12-01 18:36:21 +00:00
Dmitry Stogov
5b078e7858 Merge branch 'PHP-8.0'
* PHP-8.0:
  Disable stack reuse optimization for x86 PIC code. It may clobber local variable used for Global Offset Table.
2020-12-01 15:26:37 +03:00
Dmitry Stogov
8ad2b59e12 Disable stack reuse optimization for x86 PIC code. It may clobber local variable used for Global Offset Table. 2020-12-01 15:20:06 +03:00
Nikita Popov
715d89e166 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't use scope when validating Attribute
2020-12-01 11:50:22 +01:00
Nikita Popov
f06afc434a Don't use scope when validating Attribute
This is not safe to do at this point. Even if we made it safe,
we'd see inconsistencies due to a partially compiled class.

Fixes oss-fuzz #28129.
2020-12-01 11:49:27 +01:00
Nikita Popov
1912ff5ccb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix use after free with file cache and arena allocated strings
2020-12-01 11:32:28 +01:00
Nikita Popov
5dfec886d6 Fix use after free with file cache and arena allocated strings 2020-12-01 11:31:23 +01:00
codinghuang
3c6ab4b3ea Add const modifier for zend_extension members
Closes GH-6462.
2020-12-01 10:40:26 +01:00
Nikita Popov
c034f200aa Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't mark cpu_supports functions as always inline
2020-12-01 10:24:02 +01:00
Nikita Popov
648cda6c9f Don't mark cpu_supports functions as always inline
The use of no-sanitize may result in an inlining failure, which
will be promoted into a compile error by always-inline. Use a
normal inlining hint without enforcing it.
2020-12-01 10:22:36 +01:00
Dmitry Stogov
e1656bac7d Merge branch 'PHP-8.0'
* PHP-8.0:
  Preallocate stack space for JIT in execute_ex() to eliminate JIT prologue/epilogue.
2020-11-30 17:56:32 +03:00
Dmitry Stogov
841b00f641 Preallocate stack space for JIT in execute_ex() to eliminate JIT prologue/epilogue. 2020-11-30 17:56:08 +03:00
Nikita Popov
16795a2f83 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix build for non-x86
2020-11-27 17:04:56 +01:00
Nikita Popov
08919578ca Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix build for non-x86
2020-11-27 17:04:50 +01:00
Nikita Popov
3430d856ac Fix build for non-x86 2020-11-27 17:04:17 +01:00
Nikita Popov
3459099541 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix AVX detection
2020-11-27 14:49:57 +01:00
Nikita Popov
4f3cf983dc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix AVX detection
2020-11-27 14:49:45 +01:00
Nikita Popov
4e30ab33d8 Fix AVX detection
Our CPU detection code currently only checks whether hardware
support for AVX exists. However, we also need to check for operating
system support for XSAVE, as well as whether XCR0 has the SSE and
AVX bits set.

If this is not the case, unset the AVX and AVX2 bits in the cpuinfo
structure.

Hopefully this resolves our issues with CPU support detection.

Closes GH-6460.
2020-11-27 14:49:31 +01:00
Nikita Popov
497a0e5a0e Merge branch 'PHP-8.0'
* PHP-8.0:
  Make sure zend_cpu_supports_pclmul() is always defined
2020-11-27 12:22:53 +01:00
Nikita Popov
8e25cf26af Make sure zend_cpu_supports_pclmul() is always defined
If __builtin_cpu_supports() is available, but doesn't have support
for pclmul, the function would end up not being defined at all.
2020-11-27 12:22:03 +01:00
Nikita Popov
9234446ca0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid direct calls to zend_cpu_supports()
  Assert that cpuinfo is initialized before use
  Move avx check into a macro
2020-11-27 11:19:56 +01:00
Nikita Popov
f35b194029 Assert that cpuinfo is initialized before use
And fix some incorrect indentation.
2020-11-27 11:14:07 +01:00
Sara Golemon
c65f0c7aca
Remove -dev from ZEND_VERSION 2020-11-26 02:19:51 +00:00
Nikita Popov
7db29d2186 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80377
2020-11-25 11:48:51 +01:00
Nikita Popov
4633e70ab1 Fixed bug #80377
Make sure the $PHP_THREAD_SAFETY variable is always available
when configuring extensions. It was previously available for
phpized extensions, but for in-tree builds it was being set
too late.

Then, use $PHP_THREAD_SAFETY instead of $enable_zts to check for
ZTS in bundled extensions, which makes sure these checks also
work for phpize builds.
2020-11-25 11:47:05 +01:00
Nikita Popov
fa713ec17b Fixed bug #80362: Running dtrace scripts can cause php to crash
Patch by al at coralnet dot name.
2020-11-24 13:01:51 +01:00
Nikita Popov
61a3cff2fb Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80404
2020-11-24 11:38:50 +01:00
Nikita Popov
03f8bccaf5 Fixed bug #80404
For a division like [1..1]/[2..2] produce [0..1] as a result, which
would be the integer envelope of the floating-point result.

The implementation is pretty ugly (we're now taking min/max across
eight values...) but I couldn't come up with a more elegant way
to handle this that doesn't make things a lot more complex (the
division sign handling is the annoying issue here).
2020-11-24 11:35:44 +01:00
Nikita Popov
679bb56858 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80391
2020-11-24 10:10:01 +01:00
Nikita Popov
912cb8b8b5 Fixed bug #80391
Iterable was not considered a subtype of array|object, and thus
also not a subtype of mixed.
2020-11-24 10:09:28 +01:00
Máté Kocsis
2e4d44509b
Merge branch 'PHP-8.0' 2020-11-21 23:17:55 +01:00
Máté Kocsis
40ebfd6730
Remove some incorrect mixed parameter types 2020-11-21 23:17:35 +01:00
Nikita Popov
72ce6a131e Merge branch 'PHP-8.0'
* PHP-8.0:
  Export zend_is_callable_at_frame
2020-11-19 10:30:38 +01:00
Nikita Popov
46b9e0c874 Export zend_is_callable_at_frame
Export the zend_is_callable_impl() function as
zend_is_callable_at_frame() for use by extension. As twose pointed
out, an extension may want to retrieve fcc for a private method.
2020-11-19 10:29:32 +01:00
Nikita Popov
a6bcad4a9e Merge branch 'PHP-8.0'
* PHP-8.0:
  Short-circuit get_gc for currently running generator
2020-11-18 12:46:32 +01:00
Nikita Popov
bbc0dd402a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Short-circuit get_gc for currently running generator
2020-11-18 12:46:12 +01:00
Nikita Popov
99a8ec6e24 Short-circuit get_gc for currently running generator 2020-11-18 12:45:29 +01:00
Nikita Popov
5bd7305cf0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Provide unused retvals to observers
2020-11-17 10:30:20 +01:00
Sammy Kaye Powers
58d41b8c4f Provide unused retvals to observers
Make sure that the return value is available to observers, even if
it is not used by the caller.

Closes GH-6422.
2020-11-17 10:28:47 +01:00
Nikita Popov
c4b2a40fdd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix incorrectly optimized out live range
2020-11-17 10:20:52 +01:00
Nikita Popov
9cfb5261e4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix incorrectly optimized out live range
2020-11-17 10:20:23 +01:00
Nikita Popov
df7417d127 Fix incorrectly optimized out live range
For x ? y : z style structures, the live range starts at z, but
may also hold the value of y. Make sure that the refcounting check
takes this into account, by checking the type of a potential phi
user.
2020-11-17 10:19:57 +01:00
Sammy Kaye Powers
e974becbb1
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fire open observer end handlers after a zend_bailout
2020-11-16 15:13:29 -08:00
Sammy Kaye Powers
0425a6697a
Fire open observer end handlers after a zend_bailout
Closes GH-6377
2020-11-16 15:12:57 -08:00
Christoph M. Becker
fe27c5371e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #74558: Can't rebind closure returned by Closure::fromCallable()
2020-11-16 14:34:52 +01:00
Christoph M. Becker
c351768e4f Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74558: Can't rebind closure returned by Closure::fromCallable()
2020-11-16 14:34:28 +01:00
Christoph M. Becker
78773890f6 Fix #74558: Can't rebind closure returned by Closure::fromCallable()
Failure to rebind such closures is not necessarily related to them
being created by `ReflectionFunctionAbstract::getClosure()`, so we fix
the error message.

Closes GH-6424.
2020-11-16 14:31:06 +01:00
Dmitry Stogov
a15d215f75 Merge branch 'PHP-8.0'
* PHP-8.0:
  [Observer] Save opline before calling begin/end handlers
2020-11-11 13:07:12 +03:00
Dmitry Stogov
855d8fa68f [Observer] Save opline before calling begin/end handlers 2020-11-11 13:06:55 +03:00
Alex Dowad
ad7e0f16cc Fix mbstring support for Shift-JIS
- Reject otherwise valid kuten codes which don't map to anything in JIS X 0208.
- Handle truncated multi-byte characters as an error.
- Convert Shift-JIS 0x7E to Unicode 0x203E (overline) as recommended by the
  Unicode Consortium, and as iconv does.
- Convert Shift-JIS 0x5C to Unicode 0xA5 (yen sign) as recommended by the
  Unicode Consortium, and as iconv does.
  (NOTE: This will affect PHP scripts which use an internal encoding of
  Shift-JIS! PHP assigns a special meaning to 0x5C, the backslash. For example,
  it is used for escapes in double-quoted strings. Mapping the Shift-JIS yen
  sign to the Unicode yen sign means the yen sign will not be usable for
  C escapes in double-quoted strings. Japanese PHP programmers who want to
  write their source code in Shift-JIS for some strange reason will have to
  use the JIS X 0208 backlash or 'REVERSE SOLIDUS' character for their C
  escapes.)
- Convert Unicode 0x5C (backslash) to Shift-JIS 0x815F (reverse solidus).
- Immediately handle error if first Shift-JIS byte is over 0xEF, rather than
  waiting to see the next byte. (Previously, the value used was 0xFC, which is
  the limit for the 2nd byte and not the 1st byte of a multi-byte character.)
- Don't allow 'control characters' to appear in the middle of a multi-byte
  character.

The test case for bug 47399 is now obsolete. That test assumed that a number
of Shift-JIS byte sequences which don't map to any character were 'valid'
(because the byte values were within the legal ranges).
2020-11-09 13:45:16 +02:00
Nikita Popov
31d975a461 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80334
2020-11-09 10:19:40 +01:00
Nikita Popov
6fb3d92525 Fixed bug #80334
If assert() was called with named args, add description as named
arg as well.
2020-11-09 10:19:32 +01:00
Nikita Popov
c380812ed2 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix static variable in methods inheritance during preloading
2020-11-04 15:43:00 +01:00
Nikita Popov
670fe594b9 Fix static variable in methods inheritance during preloading
This is now "bug compatible" with the normal behavior, and more
imporantly, does not crash :)
2020-11-04 15:42:52 +01:00
Nikita Popov
3f400a7981 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't xfail method_static_var.phpt
2020-11-04 12:31:28 +01:00
Nikita Popov
57b0e5a045 Don't xfail method_static_var.phpt
Let's test the current behavior here. It might not be right, but
it's long-standing behavior.

Nearly missed an assertion failure here because the test was
XFAILed...
2020-11-04 12:30:41 +01:00
Nikita Popov
bae3a35ce6 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't disable opcache for generic tests
2020-11-04 11:12:22 +01:00
Nikita Popov
9ed2f4898b Don't disable opcache for generic tests
Even if the original issue only reproduces without opcache, we
should still allow running them with and without opcache.
2020-11-04 11:12:12 +01:00
Nikita Popov
6457043a75 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix dynamic function definition in preload script
2020-11-04 10:56:24 +01:00
Nikita Popov
c6563dddac Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix dynamic function definition in preload script
2020-11-04 10:55:59 +01:00
Nikita Popov
e0d6c3f7ba Fix dynamic function definition in preload script
We should use normal function renaming if the function is declared
during preloading itself, rather than afterwards.

This fixes a regression introduced by
68f80be9d1.
2020-11-04 10:54:08 +01:00
Nikita Popov
b43c455b98 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't disable early binding during preloading script
2020-11-03 16:47:42 +01:00
Nikita Popov
54668a449e Don't disable early binding during preloading script
We should only disable early binding during the opcache_compile_file()
calls, not inside the preloading script or anything it includes.
The right condition to check for is whether we compile the file
without execution, as declaring classes is "execution".
2020-11-03 16:45:13 +01:00
Nikita Popov
8d43896013 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix use of type copy ctor when importing trait properties
2020-11-03 15:30:00 +01:00
Nikita Popov
9fd8e00f1a Fix use of type copy ctor when importing trait properties
We shouldn't call the copy constructor inside the original type,
duh.
2020-11-03 15:29:18 +01:00
Nikita Popov
fa7272780b Merge branch 'PHP-8.0'
* PHP-8.0:
  Allow unlinked classes when performing in_compilation variance check
2020-11-03 14:50:15 +01:00
Nikita Popov
7e55317558 Allow unlinked classes when performing in_compilation variance check
As preloading runs in in_compilation mode, we also need to allow
use of unlinked classes in lookup_class().
2020-11-03 14:49:10 +01:00
Nikita Popov
b4b91a8240 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix variance checks on resolved union types
2020-11-03 14:19:53 +01:00
Nikita Popov
ee934f8245 Fix variance checks on resolved union types
This is a bit annoying: When preloading is used, types might be
resolved during inheritance checks, so we need to deal with CE
types rather than just NAME types everywhere.
2020-11-03 14:19:15 +01:00
Nikita Popov
6e30a40c28 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix typo in UPGRADING
  Improved error message for typed class properties with null as default value
2020-11-03 09:35:20 +01:00
Bogdan Ungureanu
6d6fadeb0d Improved error message for typed class properties with null as default value
Closes GH-6396.
2020-11-03 09:28:53 +01:00
Alex Dowad
2ce15d9c8d Merge branch 'PHP-8.0' 2020-10-30 22:12:00 +02:00
Alex Dowad
526c624dc4 Fix test added in d44235acae 2020-10-30 22:11:27 +02:00
Alex Dowad
e2dc80b4e4 Merge branch 'PHP-8.0' 2020-10-30 22:07:41 +02:00
Alex Dowad
d44235acae Convert numeric string array keys to integers correctly in JITted code
While fixing bugs in mbstring, one of my new test cases failed with a strange
error message stating: 'Warning: Undefined array key 1...', when clearly the
array key had been set properly.

GDB'd that sucker and found that JIT'd PHP code was calling directly into
`zend_hash_add_new` (which was not converting the numeric string key to an
integer properly). But where was that code coming from? I examined the disasm,
looked up symbols to figure out where call instructions were going, then grepped
the codebase for those function names. It soon became clear that the disasm I
was looking at was compiled from `zend_jit_fetch_dim_w_helper`.
2020-10-30 22:07:08 +02:00
Nikita Popov
ada2a55e07 Merge branch 'PHP-8.0'
* PHP-8.0:
  FIxed bug #80299
2020-10-30 17:24:02 +01:00
Nikita Popov
904c1b6589 FIxed bug #80299
The must_wrap was leaking across iterations.
2020-10-30 17:23:18 +01:00
Nikita Popov
3e2b127e63 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix SSA integrity violation for type inference in dead code
2020-10-30 15:52:59 +01:00
Nikita Popov
5958137dc5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix SSA integrity violation for type inference in dead code
2020-10-30 15:52:46 +01:00
Nikita Popov
83738281eb Fix SSA integrity violation for type inference in dead code
The foreach body can never be executed and thus may contain empty
types. We should still uphold our SSA integrity invariants in that
case.
2020-10-30 15:52:10 +01:00
Nikita Popov
b32a48f16b Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix signed integer overflow
2020-10-30 12:39:47 +01:00
Nikita Popov
085e16c301 Fix signed integer overflow
Fixes oss-fuzz #26763.
2020-10-30 12:38:27 +01:00
Dmitry Stogov
84a0d4880c Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed run-time binding of preloaded dynamically declared function
2020-10-28 13:51:55 +03:00
Dmitry Stogov
6beb080a01 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed run-time binding of preloaded dynamically declared function
2020-10-28 13:51:17 +03:00
Dmitry Stogov
68f80be9d1 Fixed run-time binding of preloaded dynamically declared function 2020-10-28 13:50:14 +03:00
Alex Dowad
d9ddeb6e85 UTF-16 text conversion handles truncated characters as illegal
This broke one old test (Zend/tests/multibyte_encoding_003.phpt), which used
a PHP script encoded as UTF-16. The problem was that to terminate the test
script, we need the text: "\n--EXPECT--". Out of that text, the terminating
newline (0x0A byte) becomes part of the resulting test script; but a bare
0x0A byte with no 0x00 is not valid UTF-16.

Since we now treat truncated UTF-16 characters as erroneous, an extra '?' is
appended to the output as an 'illegal character' marker.

Really, if we are running PHP scripts which are treated as encoded in UTF-16
or some other arbitrary text encoding (not ASCII), and the script is not
actually a valid string in that encoding, inserting '?' characters into the
code which the PHP interpreter runs is a bad thing to do. In such cases, the
script shouldn't be treated as UTF-16 (or whatever) at all.

I wonder if mbstring's encoding detection is being used in 'non-strict' mode?
2020-10-27 10:19:00 +02:00
Nikita Popov
18c4408fa5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Declare may_retry_reparse_point on windows only
2020-10-26 12:41:19 +01:00
Nikita Popov
26bd857999 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Declare may_retry_reparse_point on windows only
2020-10-26 12:41:12 +01:00
Nikita Popov
31aca85572 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Declare may_retry_reparse_point on windows only
2020-10-26 12:40:56 +01:00
Nikita Popov
824cbc2781 Declare may_retry_reparse_point on windows only 2020-10-26 12:40:45 +01:00
Christoph M. Becker
ed64d1b5a9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80258: Windows Deduplication Enabled, randon permission errors
2020-10-26 11:22:55 +01:00
Christoph M. Becker
0abcb9fb69 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80258: Windows Deduplication Enabled, randon permission errors
2020-10-26 11:22:39 +01:00
Christoph M. Becker
ac2e9587fb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80258: Windows Deduplication Enabled, randon permission errors
2020-10-26 11:21:52 +01:00
Christoph M. Becker
848e24f24d Fix #80258: Windows Deduplication Enabled, randon permission errors
A recent bug fix regarding symlinks claimed:

> After resolving reparse points, the path still may be a reparse
> point; in that case we have to resolve that reparse point as well.

While that is basically correct, some reparse points may point to
inaccessible system folders (e.g. `IO_REPARSE_TAG_DEDUP` points to
"\System Volume Information").  Since we don't know details about
arbitrary reparse points, and are mainly interested in nested symlinks,
we take a step back, and only resolve `IO_REPARSE_TAG_SYMLINK` for now.

Close GH-6354.
2020-10-26 11:21:14 +01:00
Máté Kocsis
09f4f305ec
Merge branch 'PHP-8.0' 2020-10-23 16:34:40 +02:00
Máté Kocsis
47bbfe1fc0
Require stubs to declare return types for magic methods when possible
Closes GH-6376
2020-10-23 16:33:16 +02:00
Nikita Popov
a876577ebe Merge branch 'PHP-8.0'
* PHP-8.0:
  Make GC default threshold handling consistent
2020-10-23 10:31:55 +02:00
Nikita Popov
0fb2374e06 Make GC default threshold handling consistent
While the initial threshold is set to 10001 roots, the threshold
adjustment logic may then set it to 10000. The exact value really
doesn't matter, but we should make it consistent.
2020-10-23 10:30:07 +02:00
Nikita Popov
a185cc839f Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't allow passing unknown named params to class without ctor
2020-10-23 09:47:36 +02:00
Nikita Popov
078df4d144 Don't allow passing unknown named params to class without ctor
See also https://externals.io/message/112083.

Closes GH-6364.
2020-10-23 09:46:55 +02:00
Máté Kocsis
65c4a78805
Merge branch 'PHP-8.0' 2020-10-22 19:03:04 +02:00
Máté Kocsis
a8e92e361f
Run arginfo/ZPP verification tests in strict mode as well
Closes GH-6370
2020-10-22 19:01:40 +02:00
Nikita Popov
3f0e94e3c7 Accept zend_string in highlight_string API 2020-10-22 14:35:40 +02:00
Nikita Popov
a58e371cef Remove unused single.leaf member 2020-10-22 10:42:26 +02:00
Nikita Popov
ff82234948 Merge branch 'PHP-8.0'
* PHP-8.0:
  Simplify and fix generator tree management
2020-10-22 10:27:01 +02:00
Nikita Popov
dd4a080133 Simplify and fix generator tree management
This makes a number of related changes to the generator tree
management, that should hopefully make it easier to understand,
more robust and faster for the common linear-chain case. Fixes
https://bugs.php.net/bug.php?id=80240, which was the original
motivation here.

 * Generators now only add a ref to their direct parent.
 * Nodes only store their children, not their leafs, which avoids
   any need for leaf updating. This means it's no longer possible
   to fetch the child for a certain leaf, which is something we
   only needed in one place (update_current). If multi-children
   nodes are involved, this will require doing a walk in the other
   direction (from leaf to root). It does not affect the common
   case of single-child nodes.
 * The root/leaf pointers are now seen as a pair. One leaf generator
   can point to the current root. If a different leaf generator is
   used, we'll move the root pointer over to that one. Again, this
   is a cache to make the common linear chain case fast, trees may
   need to scan up the parent link.

Closes GH-6344.
2020-10-22 10:25:25 +02:00
Nikita Popov
d1845ac008 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80255
2020-10-19 15:14:57 +02:00
Nikita Popov
d3812ca41b Fixed bug #80255
This was a copy&paste mistake, target_block was used where
follow_block was intended. Also update copy&paste mistakes in
the comments.
2020-10-19 15:13:53 +02:00
Nikita Popov
808029c049 Merge branch 'PHP-8.0'
* PHP-8.0:
  Make sure output start filename is not freed early
2020-10-16 17:29:22 +02:00
Nikita Popov
97202d9d84 Make sure output start filename is not freed early
As filenames are no longer interned, we need to keep a reference
to the zend_string to make sure it isn't freed.

To avoid a nominal source compatibility break, create a new member
in the globals.
2020-10-16 17:27:52 +02:00
Nikita Popov
60ece88c28 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix leak when setting dynamic property on generator
2020-10-16 16:58:58 +02:00
Nikita Popov
28e21d80b0 Fix leak when setting dynamic property on generator 2020-10-16 16:58:27 +02:00
Nikita Popov
a9b986a970 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix bug #80055
2020-10-15 14:24:44 +02:00
Nikita Popov
4ece62fba9 Fix bug #80055
We need to perform trait scope fixup for both methods involved
in the inheritance check. For that purpose we already need to
thread through a separate fn scope through the entire inheritance
checking machinery.
2020-10-15 14:24:25 +02:00
Nikita Popov
100ac24084 Merge branch 'PHP-8.0'
* PHP-8.0:
  Skip arginfo test under msan
2020-10-15 10:46:40 +02:00
Nikita Popov
b2700811f3 Skip arginfo test under msan
Msan is missing interceptors for some functions that result in
false positives.
2020-10-15 10:40:23 +02:00
Nikita Popov
1fc31979a4 Merge branch 'PHP-8.0'
* PHP-8.0:
  More arginfo/zpp verification
2020-10-14 16:26:27 +02:00
Nikita Popov
0832376411 More arginfo/zpp verification
Run all functions with a varying number of null arguments, which
helps us flush out all kinds of bugs.

Closes GH-5881.
2020-10-14 16:26:09 +02:00
Nikita Popov
5070549577 Sanity check zpp max argument count
This would have prevented 9b4094c.

Closes GH-6334.
2020-10-14 10:06:55 +02:00
Nikita Popov
796d06b8ab Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix handling of throwing undef var in verify return
2020-10-13 11:45:43 +02:00
Nikita Popov
1748b8111e Fix handling of throwing undef var in verify return
If we have an undefined variable and null is not accepted by the
return type, we want to throw just the undef var error.

In this case this lead to an infinite loop, because we overwrite
the exception opline in SAVE_OPLINE and it does not get reset
when chaining into a previous exception. Add an assertiong to
catch this case earlier.
2020-10-13 11:43:43 +02:00
Christoph M. Becker
2d01a89ad1 7.3.25 is next 2020-10-13 09:52:46 +02:00
Nikita Popov
c0b4dea858 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80225
2020-10-12 16:35:20 +02:00
Nikita Popov
f9b7609d17 Fixed bug #80225
Namespaced and declares have a different interpretation of what
"first statement" means.
2020-10-12 16:35:09 +02:00
Nikita Popov
14830ab2a3 Merge branch 'PHP-8.0'
* PHP-8.0:
  Detect self-addition of array more accurately
  Deindirect source elements in zend_hash_merge
2020-10-12 11:25:36 +02:00
Nikita Popov
66ecee6243 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Detect self-addition of array more accurately
  Deindirect source elements in zend_hash_merge
2020-10-12 11:25:27 +02:00
Nikita Popov
5a7f9afb99 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Detect self-addition of array more accurately
  Deindirect source elements in zend_hash_merge
2020-10-12 11:24:59 +02:00
Nikita Popov
3c4dd73c02 Detect self-addition of array more accurately
While the zvals may be different, they may still point to the
same array.

Fixes oss-fuzz #26245.
2020-10-12 11:24:31 +02:00
Nikita Popov
e304468e57 Deindirect source elements in zend_hash_merge
If the RHS has INDIRECT elements, we do not those to be added to
the LHS verbatim. As we're using UPDATE_INDIRECT, we might even
create a nested INDIRECT that way.

This is a side-quest of oss-fuzz #26245.
2020-10-12 11:24:27 +02:00
Nikita Popov
57721d6172 Merge branch 'PHP-8.0'
* PHP-8.0:
  Avoid non-object in FE_FREE
2020-10-12 09:47:22 +02:00
Nikita Popov
d953cd1862 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Avoid non-object in FE_FREE
2020-10-12 09:46:38 +02:00
Nikita Popov
304141e8f8 Avoid non-object in FE_FREE
Even if the properties HT is empty, make sure we still leave an
object in the FE_RESET result, so our type inference results
stay correct.
2020-10-12 09:45:52 +02:00
George Peter Banyard
49783e35f0 Add compiler flags which aren't included in -Wall or -Wextra
Adds the following compiler flags:
 . -Wduplicated-cond
 . -Wlogical-op
 . -Wformat-truncation
 . -fno-common

Closes GH-6199
2020-10-10 17:26:49 +01:00
Nikita Popov
5c39ac8ef5 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80186
2020-10-09 17:02:40 +02:00
Nikita Popov
623bf39e9c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80186
2020-10-09 17:02:20 +02:00
Nikita Popov
15443f8af4 Fixed bug #80186
Early exit in FE_RESET if get_properties() returns empty array,
as we cannot add HT iterators to zend_empty_array.
2020-10-09 16:56:08 +02:00
Nikita Popov
6188b7a1da Revert "Change calling convention of zval_update_constant[_ex]() to fastcall."
This reverts commit 5a447b086b.

Revert this ABI break from PHP-8.0, leaving it only on master.
2020-10-09 15:06:12 +02:00
Gabriel Caruso
14806e0824
Prepare for PHP 8.1
Closes GH-6305.
2020-10-09 11:37:27 +02:00
Dmitry Stogov
5a447b086b Change calling convention of zval_update_constant[_ex]() to fastcall. 2020-10-08 02:04:38 +03:00
Dmitry Stogov
fd81e708bc Fixed incorrect behavior of observer API.
ZEND_HANDLE_EXCEPTION might call zend_observer_fcall_end() even if exception is cought by function. The fix moved zend_observer_fcall_end() into a right place and remove OBSERVER sepecialization for ZEND_HANDLE_EXCEPTION handler.
2020-10-07 17:06:53 +03:00
Nikita Popov
edf0c6a6ae Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #80194
2020-10-07 15:03:56 +02:00
Nikita Popov
683c988493 Fixed bug #80194
We should strip NOPs from unreachable_free blocks as well, to make
sure that the free really is the first op.
2020-10-07 15:03:12 +02:00
Nikita Popov
68195bd481 Update ext/spl parameter names
Closes GH-6284.
2020-10-07 12:26:46 +02:00
Nikita Popov
ec484a0788 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #80126
2020-10-06 16:34:02 +02:00
Nikita Popov
3b7c8bb973 Fix bug #80126
When performing an unlinked instanceof, we also need to consider
interfaces of parent classes, as they may not have been inherited
yet.
2020-10-06 16:33:14 +02:00
Nikita Popov
6ea870f5fb Fix bug #80184 2020-10-05 15:24:51 +02:00
Nikita Popov
d3cf597328 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix -Wimplicit-function-declaration in configure
2020-10-05 10:48:04 +02:00