Commit Graph

16127 Commits

Author SHA1 Message Date
Christoph M. Becker
853b7945bc Unmark tests as XFAIL on Windows
This issue has been resolved[1], so the tests are expected to pass on
Windows again.

[1] <0a03291b51>
2020-09-14 10:14:21 +02:00
Christoph M. Becker
71de8fe9b8 Mark tests as XFAIL on Windows
These tests segfault with tracing JIT on Windows as of a recent
commit[1].  A link to a backtrace is available in a comment[2].  For
now, we mark these tests as XFAIL, to keep AppVeyor CI helpful.

[1] <7b0a053169>
[2] <7b0a053169 (commitcomment-42267637)>
2020-09-13 15:38:58 +02:00
Máté Kocsis
3053f6f2fa
Fix prototype of get_active_function_or_method_name() 2020-09-12 19:10:48 +02:00
Nikita Popov
b7fe1b66d0 Make argument type error message consistent for variadics
If an argument error refers to a variadic argument, we normally
do not print the name of the variadic (as it is not referring to
an individual argument, but to the collection of all of them).
However, this was not the case for the userland argument type
error message, which did it's own formatting.

Closes GH-6101.
2020-09-11 17:16:19 +02:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Hailong Zhao
9e3e83459c Remove the duplicate line in zend_ast.c
Closes GH-6107.
2020-09-11 09:51:44 +02:00
Dmitry Stogov
7b0a053169 JIT for ASSIGN_OBJ 2020-09-10 23:41:50 +03:00
Dmitry Stogov
e9b47df14f Fixed 32-bit JIT 2020-09-10 16:55:08 +03:00
Tyson Andre
09904242af Avoid gap in AST_CLASS child nodes for attributes
See https://github.com/nikic/php-ast/pull/181

> Hm, I'm thinking it would make more sense to change the structure in php-src.
> All the function types have consistent AST structure, but there's no reason at
> all why classes should be consistent with functions.

It's unusual to have an unused child node between other child nodes that are
used (for name, extends, implements, and attributes of AST_CLASS)

> That gap is a leftover from a previous refactoring. An earlier version of
> attributes extended `zend_ast_decl` with a new member called `attributes` and
> therefore did not need to handle functions and classes in different ways.

Closes GH-6088
2020-09-10 09:33:46 -04:00
Remi Collet
8710429283 fix zend_hash_get_current_key_type_ex proto 2020-09-10 12:40:47 +02:00
Remi Collet
7be70c6bfc fix zend_hash_get_current_key_ex proto 2020-09-10 12:36:44 +02:00
twosee
bd1d11d352 Simplify error type filter
Closes GH-6049.
2020-09-10 17:36:04 +08:00
Nikita Popov
73ab7b30ca Allow array_diff() and array_intersect() with single array argument
Both of these functions are well-defined when used with a single
array argument -- rejecting this case was an artificial limitation.
This is not useful when called with explicit arguments, but removes
edge-cases when used with argument unpacking:

    // OK even if $excludes is empty.
    array_diff($array, ...$excludes);

    // OK even if $arrays contains a single array only.
    array_intersect(...$arrays);

This matches the behavior of functions like array_merge() and
array_push(), which also allow calls with no array or a single
array respectively.

Closes GH-6097.
2020-09-09 11:03:17 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +02:00
twosee
40e5238a00 Flesh out ZEND_HASH_REVERSE_FOREACH_* macros
Closes GH-6080.
2020-09-09 15:12:18 +08:00
Nikita Popov
cf8d7b3eae Don't handle missing value in zend_verify_arg_error()
This error condition is handled separately, never reaches this
function.
2020-09-08 20:42:45 +02:00
Dmitry Stogov
a6a96116ac micro-optimization 2020-09-08 16:47:30 +03:00
Nikita Popov
7e339a335e Make null byte error a ValueError
Currently we treat paths with null bytes as a TypeError, which is
incorrect, and rather inconsistent, as we treat empty paths as
ValueError. We do this because the error is generated by zpp and
it's easier to always throw TypeError there.

This changes the zpp implementation to throw a TypeError only if
the type is actually wrong and throw ValueError for null bytes.
The error message is also split accordingly, to be more precise.

Closes GH-6094.
2020-09-08 15:23:23 +02:00
Dmitry Stogov
aae50328e2 decbin/decoct/dechex optimization. 2020-09-08 10:34:29 +03:00
Ilija Tovilo
8a49310f4e
Adjust assignment line number for match
Otherwise the assignment will have the same number as the default arm
which will 1. mis-trigger a breakpoint and 2. mark the line as covered
even when it isn't.

Closes GH-6083
2020-09-08 00:08:18 +02:00
Dmitry Stogov
4a2ae84188 Add "const". Move constant strings to read-only memory. 2020-09-07 21:35:48 +03:00
Nikita Popov
174dadf6b4 Don't allow dynamic properties on generators
Noticed this because we leak those properties in GC. This was
never intended to be allowed.
2020-09-07 19:08:04 +02:00
Nikita Popov
f5dbebd82e Accept zend_string instead of zval in zend_compile_string 2020-09-07 11:42:21 +02:00
Tyson Andre
ace876cdd6 Fix incorrect/unused macro
zend_ts_hash_init accepts 4 arguments, not 5.
The pHashFunction parameter was removed in 5d25762646

Closes GH-6087
2020-09-06 13:05:02 -04:00
Máté Kocsis
e50449bcb4
Use the canonical order of types in array|string ZPP error messages 2020-09-04 14:32:33 +02:00
Máté Kocsis
e50cb320b4
Add the Z_PARAM_ARRAY_HT_OR_NULL and Z_PARAM_OBJ macros 2020-09-04 14:31:27 +02:00
Nikita Popov
2e218180ef Release call trampolines in zpp fcc
When using zpp 'f' or Z_PARAM_FUNC, if the fcc points to a call
trampoline release it immediately and force zend_call_function
to refetch it. This may require additional callability checks
if __call is used, but avoids the need to carefully free fcc
values in all internal functions -- in some cases this is not
simple, as a type error might be triggered by a later argument
in the same zpp call.

This fixes oss-fuzz #25390.

Closes GH-6073.
2020-09-04 14:23:14 +02:00
Nikita Popov
fc8cfb1b1a Merge branch 'PHP-7.4'
* PHP-7.4:
  Avoid duplicate octal warning during heredoc scan ahead
2020-09-04 11:00:45 +02:00
Nikita Popov
e0a14bce77 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Avoid duplicate octal warning during heredoc scan ahead
2020-09-04 10:59:41 +02:00
Nikita Popov
e8d36ce762 Avoid duplicate octal warning during heredoc scan ahead 2020-09-04 10:58:51 +02:00
Nikita Popov
cd1c36f772 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #80049
2020-09-03 17:13:47 +02:00
Nikita Popov
2dabc4c305 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #80049
2020-09-03 17:12:58 +02:00
Nikita Popov
46a49be6c8 Fixed bug #80049
Type checking may convert to refcounted values, so force freeing
of extra args.
2020-09-03 17:12:40 +02:00
Levi Morrison
94fd52dd09 Add Z_PARAM_ITERABLE and co 2020-09-03 07:03:12 -06:00
George Peter Banyard
7b3ac296a5 Fix mismatch between macro and struct definition 2020-09-03 14:01:45 +02:00
Nikita Popov
9464576f29 Fix leaks in sapi tests
Make sure to always free compiled_filename on shutdown.
2020-09-03 12:59:30 +02:00
Nikita Popov
7620ea1580 Don't intern compiled_filename
For php-ast interning the file name is an effective memory leak,
see php-ast#134.

I don't think there's any reason to do this. At some point this
was needed due to bugs in the interned string mechanism that
caused issues if the string was later interned, e.g. through a
__FILE__ reference. These issues have since been resolved.

In conjunction with the filenames_table removal in c4016ecd44
this means that filenames now need to be refcounted like normal
strings. In particular the filename reference in op_arrays and CEs
are refcounted.
2020-09-03 12:31:23 +02:00
Nikita Popov
c4016ecd44 Remove CG(filenames_table)
This doesn't seem to serve any purpose anymore.
2020-09-03 11:33:54 +02:00
Nikita Popov
8516434a56 Fixed bug #80046
We already protect against optimizing away loop frees in DFA pass,
but not in block pass.
2020-09-03 11:19:04 +02:00
Nikita Popov
ce74ff2b3d Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #80046
2020-09-03 11:18:11 +02:00
Nikita Popov
04e77d2dea Fixed bug #80046
We already protect against optimizing away loop frees in DFA pass,
but not in block pass.
2020-09-03 11:18:01 +02:00
Nikita Popov
3b853c97f3 Fixed bug #80045
Applying the obvious fix ... however, I think we may need to
rething how we handle trampoline fcc for "f" zpp. It might make
sense to use fcc->function_handler == NULL for that case and
force it to be fetched in zend_call_function instead (it will
be reset to that after the call anyway). Otherwise we will keep
chasing these leaks, as it's the only instance where it's
necessary to free a zpp result.
2020-09-03 10:29:18 +02:00
Nikita Popov
daf222c9f8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Handle memory limit error during string reallocation correctly
2020-09-03 09:51:54 +02:00
Nikita Popov
0fc65ed133 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Handle memory limit error during string reallocation correctly
2020-09-03 09:51:35 +02:00
Nikita Popov
573ad182d2 Handle memory limit error during string reallocation correctly
Do not decrement the refcount before allocating the new string,
as the allocation operation may bail out and cause a use-after-free
lateron. We can only decrement the refcount once the allocation
has succeeded.

Fixes oss-fuzz #25384.
2020-09-03 09:49:29 +02:00
Benjamin Eberlei
8b37c1e993 Change Attribute Syntax from @@ to #[] 2020-09-02 20:26:50 +02:00
Dmitry Stogov
0d157cf526 Micro-optimization 2020-09-02 17:31:48 +03:00
Frank Du
c3299d7dab X86: Fast CRC32 computation using PCLMULQDQ instruction
Based on:
"Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
V. Gopal, E. Ozturk, et al., 2009, http://intel.ly/2ySEwL0

Signed-off-by: Frank Du <frank.du@intel.com>

Closes GH-6018
2020-09-02 15:10:41 +02:00
Máté Kocsis
3e800e997b
Move custom type checks to ZPP
Closes GH-6034
2020-09-02 11:11:38 +02:00
Nikita Popov
ddc2a2d381 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix throwing of yield from related exceptions into generator
2020-09-02 10:53:44 +02:00