Commit Graph

14577 Commits

Author SHA1 Message Date
Nikita Popov
d266ba4f2d Check for exception after calling count_values()
To avoid a duplicate error if count_values() throws.
2019-09-17 13:13:44 +02:00
David Carlier
ce25fa0d24 Monitoring anonymous pages on mac via vmmap tag 2019-09-17 12:54:46 +02:00
Nikita Popov
8c0c06da86 Merge branch 'PHP-7.3' into PHP-7.4 2019-09-16 15:01:14 +02:00
Nikita Popov
8a11f1284e Merge branch 'PHP-7.2' into PHP-7.3 2019-09-16 15:01:05 +02:00
Nikita Popov
2f6efd835d Fixed bug #78545
By using an explicit (double) cast.
2019-09-16 15:00:20 +02:00
Nikita Popov
c8359fcea2 Fix test after unserialize change 2019-09-16 11:59:43 +02:00
Nikita Popov
3f76f9416f Fix double-free on invalid large octal with separators
To clean up the mess here a bit, check for invalid octal digits
with an explicit loop instead of mixing this into the string to
number conversion.

Also clean up some type usage.
2019-09-14 12:10:06 +02:00
Nikita Popov
ee0bf4b24d Define OBJ_PROP_TO_OFFSET() using XtOffsetOf()
This avoids null pointer arithmetic UB.
2019-09-14 00:24:54 +02:00
Nikita Popov
ec30a3b171 Include stddef.h in zend_portability.h for offsetof() macro
This makes sure that we use compiler builtins when they are
available and thus avoid ubsan warnings in clang.

And also reindent the fallback implementation.
2019-09-14 00:24:47 +02:00
Nikita Popov
4226c8247f Fix use-after-free in assign-ref compilation
zend_emit_op_data may reallocate the op_array, so the assignment
of the RETURNS_FUNCTION flag may happen on an outdated opline.

Restructure the code a bit to set the flag before calling
zend_emit_op_data().
2019-09-13 18:22:14 +02:00
Dmitry Stogov
e45a757bc2 Fixed incorrect usage of QM_ASSIGN instruction 2019-09-13 12:08:59 +03:00
Dmitry Stogov
51d9f32dbe Fixed bug #78531 (Crash when using undefined variable as object 2019-09-13 01:42:02 +03:00
Dmitry Stogov
5a616191f3 Load string once 2019-09-12 18:46:13 +03:00
Dmitry Stogov
697266a84e Eliminate checks using ZEND_CONST_COND() macro 2019-09-12 18:29:19 +03:00
Nikita Popov
4b9ebd837b Allow throwing exception while loading parent class
This is a fix for symfony/symfony#32995.

The behavior is:

* Throwing exception when loading parent/interface is allowed
  (and we will also throw one if the class is simply not found).
* If this happens, the bucket key for the class is reset, so
  it's possibly to try registering the same class again.
* However, if the class has already been used due to a variance
  obligation, the exception is upgraded to a fatal error, as we
  cannot safely unregister the class stub anymore.
2019-09-12 16:41:18 +02:00
Nikita Popov
d88b212ea6 Improve "already declared" error message
If this error is missing because the rtd_key was renamed to lcname,
fetch the class based on lcname and use the class type and cased
name from there.
2019-09-11 17:04:13 +02:00
Nikita Popov
fbe287a677 Fix typo in unlinked_instanceof assertion 2019-09-11 16:50:16 +02:00
Nikita Popov
270e5e3c5b Only allow "nearly linked" classes for parent/interface
The requirements for parent/interface are difference than for the
variance checks in type declarations. The latter can work on fully
unlinked classes, but the former need inheritance to be essentially
finished, only variance checks may still be outstanding.

Adding a new flag for this because we have lots of space, but we
could also represent these "inheritance states" more compactly in
the future.
2019-09-11 16:27:28 +02:00
Christoph M. Becker
cf31210f29 PHP 7.3.10RC1 has been tagged 2019-09-10 15:11:54 +02:00
Christoph M. Becker
bcf9d1e995 new_variable '{' expr '}' is deprecated as well
Curly brace syntax for accessing array elements and string offsets is
deprecated [1]; this should also be the case for respective `new`
expressions.

This issue has been reported by brzuchal@php.net.

[1] <https://wiki.php.net/rfc/deprecate_curly_braces_array_access>
2019-09-09 19:05:23 +02:00
Nikita Popov
e81751ceac Fixed bug #78502
We need to make sure that the function is fully compiled before we
calculate the stack size. There already was a check for directly
recursive calls, but the same issue exists with indirectly recursive
calls.

I'm using DONE_PASS_TWO as the indication that the function is
fully compiled.
2019-09-06 11:33:28 +02:00
Dmitry Stogov
4ecdff2da8 Revert "Microoptimization (avoid code duplication)"
This reverts commit 25d97f5eee.
2019-09-05 15:35:19 +03:00
Dmitry Stogov
25d97f5eee Microoptimization (avoid code duplication) 2019-09-05 13:44:46 +03:00
Dmitry Stogov
7237da27fe Remove HOT attribute from some VM handlers. Comparisons almost always followed by JMPZ/JMPNZ; JMPZNZ is rare used. 2019-09-05 11:40:15 +03:00
Nikita Popov
b6f76aca54 Improve exception handling for abstract/deprecated calls
Reuse existing arg freeing loop instead of duplicating it.

Additionally also handle deprecated in DO_FCALL_BY_NAME.
2019-09-04 15:19:21 +02:00
Nikita Popov
4bb7282742 Fix handling of abstract/deprecated exception
The exception mechanism assumes that exceptions from DO_FCALL are
already happening after the function call. This means that we are
currently leaking the passed arguments, and I think we can also
corrupt the VM stack due to incorrect frame linking in some cases
(there are assertion failures if the VM stack page size is reduced).

Instead handle the stack frame freeing manually for this special
case.
2019-09-04 12:46:00 +02:00
Nikita Popov
6255308624 Report false for inherited private methods in method_exists()
These shadow methods only exist as internal implementation markers.
This mirrors the behavior of property_exists().
2019-09-03 13:59:25 +02:00
Dmitry Stogov
c739023a50 Free two bits in fn_flags by merging ZEND_ACC_HEAP_RT_CACHE/ZEND_ACC_USER_ARG_INFO and ZEND_ACC_DONE_PASS_TWO/ZEND_ACC_ARENA_ALLOCATED that may be used only for user/internal functions 2019-09-02 14:05:28 +03:00
Dmitry Stogov
e6d3a218f0 Fixed information about unused flags 2019-09-02 12:50:05 +03:00
Nikita Popov
77a0fa101e Reenable alloca support on ZTS
This got disabled due to an incorrect change in a preprocessor condition
in 2104bea5d7. It was not supposed to
be disabled.
2019-08-30 17:24:06 +02:00
Nikita Popov
6cc53981e5 Addref static vars when not copying private method
While we don't need to give this method separate static vars, we
do still need to perform an addref, as there will be a corresponding
delref in the dtor.
2019-08-29 14:47:09 +02:00
Nikita Popov
a12fe30590 Merge branch 'PHP-7.3' into PHP-7.4 2019-08-29 12:34:07 +02:00
Nikita Popov
34edd4aa2a Merge branch 'PHP-7.2' into PHP-7.3 2019-08-29 12:33:04 +02:00
Nikita Popov
ed749edd47 Fix use-after-free of immediately invoked closure with extra args 2019-08-29 12:32:03 +02:00
Nikita Popov
f912445eb2 Add missed mutability check 2019-08-28 17:35:25 +02:00
Nikita Popov
c45f19590c Remove delref in free_object_storage
This gives us better object leak diagnostics.
2019-08-28 17:04:36 +02:00
Nikita Popov
2709d6a250 Destroy error handlers before final GC run 2019-08-28 17:04:35 +02:00
Nikita Popov
ec9a96dc60 Fixed bug #78335
Destroy static properties and variables prior to the final GC run,
as they may hold GC roots.
2019-08-28 12:32:06 +02:00
Nikita Popov
e5c7f71004 Don't specify precedence for T_INC/T_DEC
As these do not operate on expressions, precedence is meaningless
for them.
2019-08-27 21:59:56 +02:00
Nikita Popov
fa8565a0f1 Merge branch 'PHP-7.3' into PHP-7.4 2019-08-26 17:52:56 +02:00
Nikita Popov
461db52400 Merge branch 'PHP-7.2' into PHP-7.3 2019-08-26 17:52:37 +02:00
Nikita Popov
589542f50c Remove properties HT from nested GC data
The properties HT may be a GC root itself, so we need to remove it.
I'm not sure this issue actually applies to PHP 7.2, but committing
it there to be safe. As seen from the test case, the handling here
is rather buggy on 7.2.
2019-08-26 17:49:37 +02:00
Nikita Popov
e2b49d6c45 Don't use needs_live_range hook for "special" live ranges
In particular we were disgarding SILENCE live ranges in opcache,
because we decided that a MAY_BE_LONG type does not need a live
range.
2019-08-26 16:12:03 +02:00
Nikita Popov
bad49e55b9 Merge branch 'PHP-7.3' into PHP-7.4 2019-08-26 10:27:08 +02:00
Nikita Popov
a26f63213d Merge branch 'PHP-7.2' into PHP-7.3 2019-08-26 10:26:49 +02:00
Nikita Popov
16d35eb643 Fix overflow in memory limit checks
Due to overflows in the memory limit checks, we were missing cases
where the allocation size was close to the address space size, and
caused an OOM condition rather than a memory limit error.
2019-08-26 10:25:30 +02:00
Theodore Brown
1a78bdab27 Fix #78454: Consecutive numeric separators cause OOM error
Resolves out of memory error when consecutive numeric separators follow a binary/hex literal.
2019-08-25 22:46:18 +02:00
Nikita Popov
d1157cbce1 Relax closure $this unbinding deprecation
Only deprecate unbinding of $this from a closure if $this is
syntactically used within the closure.

This is desired to support Laravel's macro system, see laravel/framework#29482.

This should still allow us to implement the performance improvements
we're interested in for PHP 8, without breaking existing use-cases.
2019-08-23 17:21:23 +02:00
Nikita Popov
8807889ac2 Fix arginfo leak when using disabled_classes
Also remove the hack where scope is set to NULL in order to make
free_internal_arg_info work. Instead explicitly call it for class
methods.

This fixes the asan build for Zend/tests/bug77494.phpt.
2019-08-23 17:00:59 +02:00
Christoph M. Becker
1eb75f2937 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78441: Parse error due to heredoc identifier followed by digit
2019-08-21 22:54:52 +02:00