Commit Graph

16435 Commits

Author SHA1 Message Date
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
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
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
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
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
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
526c624dc4 Fix test added in d44235acae 2020-10-30 22:11:27 +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
904c1b6589 FIxed bug #80299
The must_wrap was leaking across iterations.
2020-10-30 17:23:18 +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
085e16c301 Fix signed integer overflow
Fixes oss-fuzz #26763.
2020-10-30 12:38:27 +01: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
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
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
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
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
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
a8e92e361f
Run arginfo/ZPP verification tests in strict mode as well
Closes GH-6370
2020-10-22 19:01:40 +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
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
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
28e21d80b0 Fix leak when setting dynamic property on generator 2020-10-16 16:58:27 +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
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
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
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
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
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
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
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
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
Nikita Popov
9ad5381a2f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix -Wimplicit-function-declaration in configure
2020-10-05 10:46:46 +02:00
Nikita Popov
aa405b7da2 Fix -Wimplicit-function-declaration in configure
As this is an error with xcode 12, see bug #80171.
2020-10-05 10:43:58 +02:00
Nikita Popov
ae77c7b057 Return correct result code for division by zero
Turns out we do need to return FAILURE here on div by zero
exception. Use a three-way return value from div_function_base.

Fixes oss-fuzz #25975.
2020-10-02 12:09:14 +02:00
Nikita Popov
62c6d6952e Add test instantiating all objects
Intended to find issues in opaque object destructors.

Closes GH-6251.
2020-10-01 18:37:24 +02:00
Dmitry Stogov
773f980e00 Backport of a partial fix for bug Bug #76982 (memory leak declaring closure in included file). 2020-10-01 13:18:21 +03:00
Gabriel Caruso
0574c21b50
Prepare for PHP 8.0 RC1 2020-09-30 00:19:10 +02:00
Nikita Popov
25f1c405ff Update ext/standard parameter names
Closes GH-6214.
2020-09-29 16:49:46 +02:00
Máté Kocsis
7aa2d3519b
Zend parameter renames amendment
Closes GH-6228
2020-09-29 11:04:09 +02:00
Larry Garfield
ea03cbebbc Update PDO parameters for named arguments.
Closes GH-6220
2020-09-28 23:02:05 +01:00
Nikita Popov
36ed9966ce Allow attributes to be applied to property/constant groups
Remove arbitrary restriction that attributes cannot be applied
to property/constant groups.

The attribute applies to all elements of the group, just like
modifiers and types do.

See also https://externals.io/message/111914.

Closes GH-6186.
2020-09-27 11:35:48 +02:00
Nikita Popov
2772751b58 Make constexpr compilation robust against multiple compilation
Instead of setting the old AST type to zero, replace the AST with
the compiled constexpr AST zval. This requires passing in a
zend_ast** instead of a zend_ast*.

This allows compiling ASTs containing constexprs multiple times
-- the second time, the existing compiled representation will be
resused.

This means we no longer need to copy the attributes AST for
promoted properties.
2020-09-27 11:24:22 +02:00
Nikita Popov
5686c16db4 Honor strict_types=1 for attributes, improve backtraces
Make ReflectionAttribute::newInstance() respect the strict_types=1
declaration at the attribute use-site. More generally, pretend that
we are calling the attribute constructor from the place where the
attribute is used, which also means that the attribute location will
show up properly in backtraces and inside "called in" error information.

This requires us to store the attributes strict_types scope (as flags),
as well as the attribute line number. The attribute filename can be
recovered from the symbol it is used on. We might want to expose the
attribute line number via reflection as well.

See also https://externals.io/message/111915.

Closes GH-6201.
2020-09-27 10:42:58 +02:00
Sammy Kaye Powers
e42abeafec
Pass zend_execute_data instead of zend_function to fcall init
The motivation for this change is to prevent extensions from having to check executor globals for the current execute_data during function call init. A previous implementation of the observer API initialized the function call from runtime cache initialization before execute_data was allocated which is why zend_function was passed in.

But now that the observer API is implemented via opcode specialization, it makes sense to pass in the execute_data. This also keeps the API a bit more consistent for existing extensions that already hook zend_execute_ex.

Closes GH-6209
2020-09-25 11:46:15 -07:00
Nikita Popov
450f2ff406 Skip unnecessary unknown() frames
Noticed this while working on attributes strict_types handling.
We sometimes insert dummy frames internally, but I don't think
these should show up in debug_backtrace output unless they're
needed, either to display an include call or to preserve file/line
information that would otherwise get lost.

Closes GH-6195.
2020-09-24 10:34:24 +02:00
Nikita Popov
12d087c346 Use C zpp for get_class_vars() 2020-09-22 13:05:05 +02:00
George Peter Banyard
2ee7e2982f Promote count() warning to TypeError
Closes GH-6180
2020-09-21 21:29:15 +01:00
Nikita Popov
fb4554e431 Throw warning for failed object to int/float conversion
We previously couldn't increase the error level here because it
was coupled to comparison handling. This is no longer the case
in PHP 8.
2020-09-21 17:04:39 +02:00
Nikita Popov
d60c43e397 Convert exception instanceof checks to assertions 2020-09-21 17:04:39 +02:00
Nikita Popov
edf22962ef Make constant redeclaration a warning
We missed the change to make this an Error exception in PHP 8,
but at least elevate it to a warning, to avoid a notice -> exception
jump at a later time.
2020-09-21 17:04:39 +02:00
Christoph M. Becker
3e33e1e86d Check linker compatibility directly from HMODULE
Checking the linker compatibility with extranous `ImageLoad()` calls is
possible, but unnecessary, since the modules are either already loaded
or loaded shortly afterwards, so that we can get the required
information directly from the module handles.  And actually, doing
`ImageLoad()` as well as `LoadLibrary()` leaves a tiny room for a race
condition, because both functions will lookup the module in the search
path, so there is no *guarantee* that both are dealing with the same
module.  Dropping the `ImageLoad()` calls also has the advantage to no
longer face the issue reported in bug #79557.  A very minor additional
advantage is that we no longer have to link against Imagehlp.dll.

Furthermore, there is no need to check for CRT compatibility multiple
times, so we can simplify the signature of `php_win32_crt_compatible`,
and at the same time clean up main.c a bit.

These changes require to change the signature of the exported
`php_win32_image_compatible` and `php_win32_crt_compatible` functions,
which now expect a `HMODULE` and nothing, respectively, instead of the
module name.
2020-09-21 16:25:31 +02:00
Nikita Popov
213b666781 Synchronize GET_CLASS/GET_CALLED_CLASS opcodes with functions
These error conditions throw in the function implementations,
make the opcodes match.
2020-09-21 15:06:04 +02:00
Nikita Popov
d085a7439f Assert on unknown list entry type 2020-09-21 14:58:23 +02:00
Nikita Popov
3642592a12 Remove unnecessary check
We should only produce IS_UNDEF if an exception is thrown, this
check is not needed.
2020-09-21 14:56:14 +02:00
Nikita Popov
8e0789a21c Use proper parameter type in Closure::bindTo() signature 2020-09-21 14:46:10 +02:00
Máté Kocsis
4c821cf206
Improve default value handling of Exception constructors
Closes GH-6166
2020-09-21 12:46:50 +02:00
Nikita Popov
c5f93d191e Fix detection of code outside namespace
Due to improvements to early binding, the opcode based check is
no longer accurate. Reuse the syntactic check we're already using
for declares instead.
2020-09-21 12:37:44 +02:00
Nikita Popov
ef9ab9159b Use assertion for null-termination string
Indicates an implementation bug, make sure we can automatically
detect it.
2020-09-21 12:12:51 +02:00
Nikita Popov
2bf2cede89 Initialize attributes for internal functions
Fixes a crash in Symfony SecurityBundle tests.
2020-09-21 10:50:29 +02:00
Máté Kocsis
64af12d13b
Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Máté Kocsis
b15885b522
Separate Closure::bind() implementations
Closure::bind() and Closure::bindTo() are currently reported as aliases in stubs because they have a single implementation. They are not aliases in fact though, they just use zend_parse_method_parameters() cleverly.

Thus, let's separate their implementation so that we don't have to alias Closure::bindTo() anymore. This will also have the advantage that the two ZPP implementations become more clear.

Closes GH-6169
2020-09-19 20:14:22 +02:00
Sammy Kaye Powers
12306728c5
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart.

Closes GH-5871
2020-09-18 14:26:44 -07:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Dmitry Stogov
d5d31ea3b3 Cleanup observer API and add JIT support 2020-09-18 12:55:58 +03:00
Nikita Popov
34bb5ba2ea Remove support for EXT_NOP
This is an annoying edge case that regularly gets broken. As we're
not aware of significant users of this API, and there are other
ways to hook this, remove support for EXT_NOP.
2020-09-18 11:03:08 +02:00
Sammy Kaye Powers
9e94bcfdbc Remove specialization of SPEC(OBSERVER) handlers 2020-09-18 00:47:36 +03:00
Nikita Popov
e3d0bc0a98 Fixed bug #80109
Skip over leading EXT_NOP, if it exists.
2020-09-17 09:59:51 +02:00
Bob Weinand
6d538e83aa Fix OSS Fuzz issue: yielding from an aborted generator 2020-09-15 20:07:33 +02:00
Nikita Popov
7e61c2edd8 Fix uninitialized run-time cache when resolving named param defaults
Fixes oss-fuzz #25676.
2020-09-15 16:51:56 +02:00
Nikita Popov
3c53732332 Fix undef var exception handling in JMP_NULL
We need to initialize the result variable in the exceptional
case as well.

Fixes oss-fuzz #25526.
2020-09-15 15:44:01 +02:00
Nikita Popov
a009d370e9 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix assumption about property guard hash value
2020-09-15 15:27:17 +02:00
Nikita Popov
2bbf2a91aa Fix assumption about property guard hash value
The "member" string here does not necessarily have a pre-calculated
hash value. In particular this is not the case if the class has no
properties.

Fixes oss-fuzz #25546.
2020-09-15 15:26:41 +02:00
Nikita Popov
16b9f19678 Fix compile-time/run-time discrepancies with unary operators
This addresses two issues:
 * ~ throws for a number of types, and we should not compile-time
   evaluate in that case. Add a check similar to what we do for
   binary ops.
 * Unary +/- may produce a different error message due to
   canonicalization of the constant operand to the RHS. To avoid
   this, put the constant operand on the RHS right away.

Fixes oss-fuzz #25649.
2020-09-15 15:08:55 +02:00
Máté Kocsis
c37a1cd650
Promote a few remaining errors in ext/standard
Closes GH-6110
2020-09-15 14:26:16 +02:00
Nikita Popov
da0663a337 Add GC_TRY_ADDREF macro
That adds a ref if not immutable. Also audit uses of GC_IMMUTABLE
to either use GC_TRY_ADDREF or GC_TRY_PROTECT_RECURSION.
2020-09-15 11:41:09 +02:00
Christoph M. Becker
edddddcea8 7.3.24 is next 2020-09-15 10:51:41 +02:00
Dmitry Stogov
8f93709d7d micro-optimization 2020-09-15 09:39:41 +03:00
Dmitry Stogov
3228d685e2 Renumber ZEND_ACC_... constants 2020-09-15 09:39:27 +03:00
Bob Weinand
452f7b0d41 Fix use-after-free with yield from in yield_from_multi_tree_single_nodes.phpt
Prevent release of generator children during destruction
2020-09-14 23:07:01 +02:00
Bob Weinand
ad61e141dd Fix crashes with unproper cleaning of repeated yield from
Closes GH-6130
2020-09-14 20:49:24 +02:00
Benjamin Eberlei
1359a52d5b Rename zend_error_notify APIs to zend_observer_error* 2020-09-14 19:29:14 +02:00
Larry Garfield
96f2f3174b Update array parameter names for named parameters
* The array "subject" of a function gets called $array.

* Further parameters should be self-descriptive if used
  as a named parameter, and a full word, not an abbreviation.

* If there is a "bunch more arrays" variadic, it gets
  called $arrays (because that's what was already there).

* A few functions have a variadic "a bunch more arrays,
  and then a callable", and were already called $rest.
  I left those as is and died a little inside.

* Any callable provided to an array function that acts
  on the array is called $callback. (Nearly all were already,
  I just fixed the one or two outliers.)

* array_multisort() is beyond help so I ran screaming.
2020-09-14 14:56:49 +00:00
Nikita Popov
57a4a2c5a8 Fixed bug #80096
We shouldn't assume that call->prev_execute_data is NULL here. The
value needs to be preserved for call chains.
2020-09-14 15:49:49 +02:00
George Peter Banyard
31ef94cd42 Convert Division by 0 warnings to Error per the Engine Warning RFC
Closes GH-6125
2020-09-14 13:40:07 +02:00
Máté Kocsis
46c0c82a0f
Declare array|int and object-of-class|int types in stubs
Closes GH-6081

Co-Authored-By: Nikita Popov <nikic@php.net>
2020-09-14 11:59:32 +02:00
Máté Kocsis
7e0631e5ee
Add Z_PARAM_OBJ_OF_CLASS ZPP macro 2020-09-14 11:40:27 +02:00
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
Nikita Popov
c6fd37cee3 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix throwing of yield from related exceptions into generator
2020-09-02 10:53:13 +02:00
Nikita Popov
2e9e706a82 Fix throwing of yield from related exceptions into generator
Use the general zend_generator_throw_exception() helper for this.
Otherwise we don't handle the off-by-one opline correctly (should
we maybe just stop doing that?)

This is a followup to ad750c3bb6,
which fixed a different yield from exception handling problem that
happened to show up in the same test case from oss-fuzz #25321.
Now both issues should be fixed.
2020-09-02 10:52:55 +02:00
Nikita Popov
8b6b2bda09 Fix by-ref list assign LIST_W+MAKE_REF separation
Shift the responsibility for emitting MAKE_REF to the list assignment
code, to make sure that LIST_W and MAKE_REF are directly adjacent,
and there are no opcodes in between that could modify the LIST_W
result.

Additionally, adjust the zend_wrong_string_offset() code to not
perform a loop over opcodes and assert that the next opcode is
a relevant one. The VM write-safety model requires this.

This is a followup to a07c1f56aa
and the full fix for oss-fuzz #25352.
2020-09-02 10:26:55 +02:00
Nikita Popov
aedc7b0fb4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix infinite loop on string offset during by-ref list assign
2020-09-02 10:16:46 +02:00
Nikita Popov
605ee9c8eb Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix infinite loop on string offset during by-ref list assign
2020-09-02 10:16:35 +02:00
Nikita Popov
a07c1f56aa Fix infinite loop on string offset during by-ref list assign
There is a deeper underlying issue here, in that the opcodes violate
VM write-fetch safety, but let's fix the infinite loop first.

This fixes oss-fuzz #25352.
2020-09-02 10:16:05 +02:00
Nikita Popov
a8687804bb Disable ifunc resolvers under dataflow sanitizer
As with other sanitizers, this is not supported.
2020-09-01 20:37:43 +02:00
Nikita Popov
c6ea0e90c2 Assert there are children in zend_generator_get_child() 2020-09-01 20:37:43 +02:00
Levi Morrison
66c3e900e2 Add zend_observer API
Closes GH-5857.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
2020-09-01 09:59:59 -06:00
Máté Kocsis
f7fbc6333f
Add more precise type info for stubs
Closes GH-6005
2020-09-01 16:35:56 +02:00
Nikita Popov
88a8ebce6a Merge branch 'PHP-7.4'
* PHP-7.4:
  Check for null EX(func) in write_property
2020-09-01 15:17:28 +02:00
Nikita Popov
f92a03627a Check for null EX(func) in write_property
This can happen if zend_call_function inserted a dummy frame,
and we already switched to the dummy frame in leave_helper,
and an exception is thrown during CV destruction.

Fixes oss-fuzz #25343.
2020-09-01 15:16:41 +02:00
George Peter Banyard
5c1cf7669b Prepend compiler warning flags to CFLAG instead to append them
Credit to @bwoebi for the idea

Closes GH-6057
2020-09-01 14:45:57 +02:00
Nikita Popov
48e31be7a3 Fix FE_FETCH_R_SIMPLE specialization
After a99d08b5d1 the type can
include UNDEF. However, UNDEF can only reach FE_FREE, not FE_FETCH.
As such, simply ignore this type.
2020-09-01 14:43:06 +02:00
Nikita Popov
a99d08b5d1 Fix type inference for FE_RESET on invalid type
FE_RESET sets the result to UNDEF in this case. We should infer
some type here, because no type generally implies unreachable
code. In this case SCCP ended up replacing the FE_RESET result
with null, including in FE_FREE.
2020-09-01 13:59:36 +02:00
Nikita Popov
c088a9369f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix pi node removal when removing predecessor
2020-09-01 12:26:18 +02:00
Nikita Popov
37612936a1 Fix pi node removal when removing predecessor
We can't just remove the uses, we need to replace uses.

The test case only fails on master with SSA integrity violations,
but I believe the root issue also existed previously.
2020-09-01 12:25:00 +02:00
Nikita Popov
4acac9bd72 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix leak on assign concat of array and empty string
2020-08-31 17:06:21 +02:00
Nikita Popov
9560e3ba7a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix leak on assign concat of array and empty string
2020-08-31 17:05:55 +02:00
Nikita Popov
cd2afd99b1 Fix leak on assign concat of array and empty string 2020-08-31 17:05:31 +02:00
Nikita Popov
2022f2e5c9 Fix nullsafe operator with delayed oplines
Closes GH-6056.
2020-08-31 16:44:36 +02:00
Ilija Tovilo
70300f6c9d Add tests for nullsafe operator on delayed oplines 2020-08-31 16:44:36 +02:00
Nikita Popov
50975640bc Fixed bug #80030 2020-08-31 12:38:11 +02:00
Nikita Popov
570f463fb8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #80037
2020-08-31 12:19:00 +02:00
Nikita Popov
dfaa4768d2 Fix bug #80037
If we're accessing an uninitialized typed property and __get is
defined, don't perform a read_property callback, as __get is
supposed to have no effect on uninitialized typed properties.
Usually it doesn't, but by-reference assignments cannot be
performed through read_property.

I'm deleting the test for bug #80039 again, as it doesn't really
make sense anymore with this fix.
2020-08-31 12:17:00 +02:00
Nikita Popov
0e9d76ee62 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add test for bug #80039
2020-08-31 11:22:51 +02:00
Nikita Popov
8f7c529720 Add test for bug #80039
This has already been fixed by 247105ae1a,
but let's add the additional test case.
2020-08-31 11:22:16 +02:00
Nikita Popov
ad97739eac Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix handling of exception if valid() during yield from
2020-08-31 10:52:07 +02:00
Nikita Popov
b396fb348b Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix handling of exception if valid() during yield from
2020-08-31 10:51:49 +02:00
Nikita Popov
ad750c3bb6 Fix handling of exception if valid() during yield from
Fixes oss-fuzz #25296.
2020-08-31 10:51:31 +02:00
Nikita Popov
061c708a93 Correctly report failure in zend_handle_undef_args()
And do the check before increfing the closure object, otherwise
we'd have to release it as well.

Fixes oss-fuzz #25313.
2020-08-31 10:37:55 +02:00
Nikita Popov
e81becce08 Fix trampoline leak in array_map 2020-08-31 10:14:39 +02:00
Jamie Liu
c8093fe94a Fix bug #80018: Tolerate var_dump() printing floats in exponential notation in tests 2020-08-31 09:51:01 +02:00
twosee
f982038fb6 Merge branch 'PHP-7.4'
* PHP-7.4:
  Improve error_handing replacement functions

# Conflicts:
# Zend/zend_API.c
2020-08-30 17:06:59 +08:00
twosee
45ed9b42a5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Improve error_handing replacement functions
2020-08-30 16:25:12 +08:00
twosee
e948188832 Improve error_handing replacement functions
We explicitly skip calls to user_error_handler in EH_THROW mode

Closes GH-6050.
2020-08-30 16:24:42 +08:00
Nikita Popov
86364013f9 Avoid ubsan warning with dummy cache slot addr 2020-08-28 17:24:21 +02:00
Nikita Popov
927771333b Fix unused variable warning 2020-08-28 17:19:32 +02:00
Nikita Popov
b2bc2c62fa Remove unnecessary cache_slot arguments
zend_verify_type_error_common() no longer needs the cache_slot,
so drop it there and from all users.
2020-08-28 17:15:09 +02:00
Nikita Popov
2c15c9ce80 Rehash function table after disabling functions
To perform fast shutdown without full table cleanup we need all
internal functions to be in one continuous chunk. This was
violated when functions were deleted via disable_functions.

This drops the zend_disable_function() API in favor of
zend_disable_functions(), which disables the given list of
functions and performs the necessary rehash afterwards.

Also drop PG(disabled_functions), which is no longer used.
2020-08-28 16:50:07 +02:00
Nikita Popov
138f141605 Don't mark variadic functions as ZEND_FASTCALL
Variadic functions do not support the fastcall calling convention.
2020-08-28 16:45:13 +02:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
Nikita Popov
5db44e39b1 Fix tracked_realloc
We should only drop the information about the old allocation after
checking the memory limit. This makes the code a bit more awkward...
2020-08-28 11:37:42 +02:00
Nikita Popov
32315c247f Promote incomplete class to modification to Error
In line with engine diagnostic promotions, property writes throw
an Error exception, while reads throw a warning.
2020-08-28 11:14:43 +02:00
Nikita Popov
df5011f56c Export and reuse zend_is_valid_class_name API
Unserialization does the same check as zend_lookup_class, so let's
share the same optimized implementation.
2020-08-28 10:06:01 +02:00
Nikita Popov
a2bbd8f01f Fix leak in typed reference assignment
We're only creating tmp here to compare against the existing
coerced_value. We need to destroy it in all cases.
2020-08-27 14:40:35 +02:00
Nikita Popov
614c0b846e Allow removing non-existing key from WeakMap
In line with usual PHP semantics. This previously triggered an
assertion failure.
2020-08-27 12:42:08 +02:00
Nikita Popov
0026d8a783 Fix use-after-free is WeakMap key and value are the same
Drop the object from the WeakMap as the last step, as this might
end up destroying the object.
2020-08-27 12:05:06 +02:00
Nikita Popov
bd6feb7b12 Enforce memory limit in tracked allocation mode
A very basic limit (for single allocations) was already enforced.
This extends it to count the total memory allocations.

This is useful to avoid out of memory conditions while fuzzing.
2020-08-27 10:18:18 +02:00
Nikita Popov
e069032e5c Merge branch 'PHP-7.4'
* PHP-7.4:
  Property handle read_property exception in fetch_property_address
2020-08-26 16:13:10 +02:00
Nikita Popov
247105ae1a Property handle read_property exception in fetch_property_address
Otherwise we leak (and corrupt uninitialized_zval).
2020-08-26 16:12:34 +02:00
Nikita Popov
55798e0e39 Lowercase method name in zend_call_method() 2020-08-26 15:19:23 +02:00
Nikita Popov
86cd009718 Fix pass by ref error for named params 2020-08-26 15:10:08 +02:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Nikita Popov
795ad1e354 Fix memory leak on unknown named param in iterator unpack 2020-08-26 12:19:17 +02:00
Nikita Popov
1003ae2692 Fix passing of undef var to named arg
This needs to use the previously computed argument target.
2020-08-26 11:53:02 +02:00
Nikita Popov
492621f99e Fix memory leak on unknown named param 2020-08-26 11:44:15 +02:00
Nikita Popov
d7d2b060e1 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix memory leak when yielding from non-iterable
2020-08-26 11:32:56 +02:00
Nikita Popov
bf3e772361 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix memory leak when yielding from non-iterable
2020-08-26 11:32:31 +02:00
Nikita Popov
d179e34e42 Fix memory leak when yielding from non-iterable 2020-08-26 11:32:01 +02:00
Nikita Popov
1954aed745 Fix over-eager named params optimization
We can't relax a named param to a positional param if we encountered
any unknown parameters in the meantime.
2020-08-26 11:01:15 +02:00
Dmitry Stogov
2369f48092 Infer information about packed/hash arrays and use it for JIT 2020-08-25 18:28:23 +03:00
Máté Kocsis
6c8fb123d2
Promote warnings to exceptions in ext/simplexml
Closes GH-6011

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-08-25 15:15:58 +02:00
twosee
9f05c32704 Remove useless same_zval function
Closes GH-6039.
2020-08-25 18:02:38 +08:00
Nikita Popov
7a6ae9b148 Fix refcounting for the named params case as well
Adjust the test case to pass a refcounted value and to also check
the named params case.
2020-08-24 16:30:49 +02:00
Nikita Popov
779e904465 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix refcounting
2020-08-24 16:23:33 +02:00
Nikita Popov
bb54694f4f Fix refcounting 2020-08-24 16:23:19 +02:00
Christoph M. Becker
5643f34a1e Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #79979: passing value to by-ref param via CUFA crashes
2020-08-24 15:03:26 +02:00
Christoph M. Becker
6b6c2c003c Fix #79979: passing value to by-ref param via CUFA crashes
If a by-val send is not allowed, we must not do so.  Instead we wrap
the value in a temporary reference.

Closes GH-6000
2020-08-24 14:08:32 +02:00
Nikita Popov
9395e01e3d Check variadic parameter for type and duplicate name
Set HAS_TYPE_HINTS flag if the variadic parameter is types as well,
and make sure it has a distinct name. This was previously missed,
because the variadic parameter is not part of num_args.
2020-08-24 10:15:57 +02:00
Dmitry Stogov
5c18ee58b9 Fixed use-after-free introduced by aed1f78515 2020-08-24 09:50:54 +03:00
Christoph M. Becker
13419befff Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix wrong datatype
2020-08-21 15:30:07 +02:00
Christoph M. Becker
8f9f308bb9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix wrong datatype
2020-08-21 15:28:37 +02:00
Manuel Mausz
46d62e5464 Fix wrong datatype
ini_entry->modifiable is of type uint8_t and so should be the temp. variable. Especially important after 4b77a158.

Closes GH-6028
2020-08-21 15:28:12 +02:00
Dmitry Stogov
aed1f78515 micro-optimization 2020-08-20 15:02:12 +03:00
Christoph M. Becker
ff14b7adad 7.3.23 is next 2020-08-18 09:55:37 +02:00
Nikita Popov
befe10fd21 Fix bug #78770
Refactor the zend_is_callable implementation to check callability
at a particular frame (this is an implementation detail for now,
but could be exposed in the API if useful). Pick the first parent
user frame as the one to check.
2020-08-14 10:24:06 +02:00
Nikita Popov
b03e300a29 Fix test after PDOStatement::fetchObject() change 2020-08-13 16:45:32 +02:00
Nikita Popov
670036e2a9 Use Z_PARAM_CLASS in PDOStatement::fetchObject()
Instead of implementing custom logic.
2020-08-13 16:20:29 +02:00
Tyson Andre
1e9a5c67ef Rename standard array function parameters to $array
This is targeting 8.0.

`$arg` seems like a poor choice of a name,
especially if the function were to have arguments added.

In many cases, the php.net documentation already has $array for these functions.
E.g. https://www.php.net/manual/en/function.array-intersect.php

I'd assume that since named arguments was added to 8.0 near the feature freeze,
PHP's maintainers had planned to make the names consistent
and gradually use the same name for  docs and implementation.
2020-08-11 19:11:59 -04:00
Ilija Tovilo
10f660f0a5
Fix ?-> in encaps vars without braces
Closes GH-5966.
2020-08-11 21:16:44 +02:00
Nikita Popov
e25aab6426 Fixed bug #79927
We need to unset the AT_FIRST_YIELD flag when yielding from an
array as well.

In the interest of being conservative, I'm applying this only to
PHP 8.
2020-08-11 15:48:40 +02:00
Nikita Popov
227f1f1481 Fix nullsafe operator on $this 2020-08-11 15:22:14 +02:00
Nikita Popov
42eda5160d SAVE_OPLINE in NULL_HANDLER
Let's avoid crashing before the nice error message gets printed...
2020-08-11 15:14:50 +02:00
Nikita Popov
f491dabe40 Fix nullsafe operator on reference
Dereference the value before checking the type. As the happy path
necessarily has to check for references, I'm not bothering to
delay the comparison.
2020-08-11 15:11:36 +02:00
Nikita Popov
c439f1fa6a Fixed bug #62294
The primary issue was already resolved in 7c3e487289,
but the particular example used in this bug report ran into an
additional issue on PHP 8, because I forgot to drop a number of
zend_bailout calls when switch require failure to throw.
2020-08-10 12:54:02 +02:00
Nikita Popov
ee16316148 Fixed bug #79948
Make sure we don't execute further scripts if one of them encountered
an exit exception.

Also make sure that we free file handles that end up unused due to
an early abort in php_execute_scripts(), which turned up as an
issue in the added test case.

Finally, make use of EG(exit_status) in the places where we
zend_eval_string_ex, instead of unconditionally assigning exit
code 254. If an error occurs, the error handler will already set
exit status 255.
2020-08-10 11:15:16 +02:00
Nikita Popov
896dad4c79 Fixed bug #77561
Unconditionally strip shebang lines when using the CLI SAPI,
independently of whether they occur in the primary or non-primary
script. It's unlikely that someone intentionally wants to print
that shebang line when including a script, and this regularly
causes issues when scripts are used in multiple contexts, e.g.
for direct invocation and as a phar bootstrap.
2020-08-10 10:38:33 +02:00
Nikita Popov
74c4381806 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79947
2020-08-10 10:13:34 +02:00
Nikita Popov
2d087210eb Fixed bug #79947
Move the FREE_OP for op_data out of the zend_binary_assign_op_dim_slow()
slow path, so it can be used by the other error path as well. This
makes ASSIGN_DIM_OP structurally more similar to ASSIGN_DIM.
2020-08-10 10:11:56 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00