Commit Graph

15468 Commits

Author SHA1 Message Date
Nikita Popov
ec0ce49f5c Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #76047
2020-01-31 10:30:09 +01:00
Nikita Popov
d422478f6d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #76047
2020-01-31 10:29:45 +01:00
Nikita Popov
ef1e4891b4 Fix bug #76047
Unlink the current stack frame before freeing CVs or extra args.
This means it will no longer show up in back traces that are
generated during CV destruction.

We already did this prior to destructing the object/closure,
presumably for the same reason.
2020-01-31 10:26:40 +01:00
Akim Demaille
37d0f7d3b3
Use "%empty" in the parsers, instead of comments
The annotation %empty is properly enforced: warnings when it's
missing, and errors when it's inappropriate.  Support for %empty was
introduced in Bison 3.0.

Pass -Wempty-rule to Bison.

Closes GH-5134
2020-01-31 09:52:40 +01:00
Dmitry Stogov
7ebf1d44ed Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79094 (Crashing when running recursion function)
2020-01-31 10:34:28 +03:00
Dmitry Stogov
db7193f31e Fixed bug #79094 (Crashing when running recursion function) 2020-01-31 10:34:04 +03:00
Nikita Popov
981fdd9f51 Merge branch 'PHP-7.4'
* PHP-7.4:
  fix cross compilation failure due to size_t typecast in define
2020-01-30 15:52:22 +01:00
Pascal de Bruijn
f0f5c415a6 fix cross compilation failure due to size_t typecast in define
The following commit introduces a cross-compilation failure:

   93c728b77c
  "Try to control ZEND_MM_ALIGNED_SIZE type"

br-arm-full/build/php-7.4.2/Zend/zend_alloc.h:30:38:
error: missing binary operator before token "8"
                                              ^
br-arm-full/build/php-7.4.2/ext/opcache/ZendAccelerator.c:1380:7:
note: in expansion of macro ‘ZEND_MM_ALIGNMENT’

Closes GH-5128.
2020-01-30 15:51:54 +01:00
Nikita Popov
38e27625ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix live range calculation for FE_FETCH
2020-01-30 14:24:28 +01:00
Nikita Popov
be7eab3202 Fix live range calculation for FE_FETCH
Op2 is def here, not a use, so treat it accordingly.
2020-01-30 14:23:46 +01:00
Nikita Popov
24a3d0dbd0 Update test for warning -> fatal error change 2020-01-30 12:12:09 +01:00
Nikita Popov
d5dd46fb09 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix copying of functions in variance obligations
2020-01-30 11:56:36 +01:00
Nikita Popov
68596ed71e Fix copying of functions in variance obligations
Only copy sizeof(zend_internal_function) for internal functions.
2020-01-30 11:55:38 +01:00
Nikita Popov
cb7b21009b Merge branch 'PHP-7.4'
* PHP-7.4:
  Reset trampoline on executor startup
  Fix UAF in is_callable() and allocated trampoline
2020-01-30 11:05:56 +01:00
Nikita Popov
98deece6f7 Reset trampoline on executor startup
Make sure the trampoline is usable, even if we had an unclean
shutdown on the last request.
2020-01-30 11:05:04 +01:00
Nikita Popov
429f194f40 Fix UAF in is_callable() and allocated trampoline
By nulling out the function_handler, so it will not get used
below. Reuse the existing helper for this purpose.
2020-01-30 11:04:59 +01:00
Nikita Popov
a73df8e5f9 Merge branch 'PHP-7.4'
* PHP-7.4:
  Use "%define parse.error verbose"
2020-01-29 11:16:38 +01:00
Akim Demaille
5265fabc25 Use "%define parse.error verbose"
The YYERROR_VERBOSE macro will no longer be supported in Bison 3.6.
It was superseded by the "%error-verbose" directive in Bison 1.875
(2003-01-01).  Bison 2.6 (2012-07-19) clearly announced that support
for YYERROR_VERBOSE would be removed.  Note that since Bison 3.0
(2013-07-25), "%error-verbose" is deprecated in favor of "%define
parse.error verbose".

Closes GH-5125.
2020-01-29 11:16:30 +01:00
Nikita Popov
d91b166c3a Avoid shift UB for large arrays
Don't shift into the sign bit.
2020-01-28 15:34:08 +01:00
Nikita Popov
c59219de85 Perform map ptr base arithmetic through uintptr_t
Adding an offset to the NULL pointer is undefined behavior.
Avoid this by performing arithmetic on uintptr_t instead.
2020-01-28 11:24:04 +01:00
Nikita Popov
521c405108 Don't index NULL pointer when fetching non-existent constant 2020-01-28 11:20:57 +01:00
Nikita Popov
3bae1793ab Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #78989
2020-01-28 10:44:37 +01:00
Nikita Popov
1146bdb9b2 Fixed bug #78989
Always operate on copies of the functions, so we don't reference
temporary trait methods that have gone out of scope.

This could be more efficient, but doing an allocated copy only when
strictly necessary turned out to be somewhat tricky.
2020-01-28 10:43:15 +01:00
Nikita Popov
e72bf63691 Allow variadic arguments to replace non-variadic ones
Any number of arguments can be replaced by a variadic one, so
long as the variadic argument is compatible (in the sense of
contravariance) with the subsumed arguments.

In particular this means that function(...$args) becomes a
near-universal signature: It is compatible with any function
signature that does not accept parameters by-reference.

This also fixes bug #70839, which describes a special case.

Closes GH-5059.
2020-01-23 15:23:31 +01:00
Christoph M. Becker
28e650abf8 Revert "Merge branch 'PHP-7.4'"
This reverts commit 046dcfb531, due to
segfaults on Travis.  This needs to be investigated.
2020-01-23 13:12:16 +01:00
Nikita Popov
9c23a50939 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79155
2020-01-23 12:55:59 +01:00
Nikita Popov
2eb33818b6 Fixed bug #79155
Make sure we only unset the NULLABLE flag temporarily for class
resolution, as the same type may be compiled multiple types.
2020-01-23 12:54:14 +01:00
Christoph M. Becker
046dcfb531 Merge branch 'PHP-7.4'
* PHP-7.4:
  Make MSVCRT memory leak checking usable for the test suite
2020-01-23 11:48:20 +01:00
Christoph M. Becker
4130fe437a Make MSVCRT memory leak checking usable for the test suite
While basic support for MSVCRT debugging has been added long
ago[1], the leak checking is not usable for the test suite, because we
are no longer calling `xmlCleanupParser()` on RSHUTDOWN of
ext/libxml[2], and therefore a few bogus leaks are reported whenever
ext/libxml is unloaded.

We therefore ignore memory leaks for this case.  We introduce
`ZEND_IGNORE_LEAKS_BEGIN()` and `ZEND_IGNORE_LEAKS_END()` to keep
those ignores better readable, and also because these *might* be
useful for other leak checkers as well.

We also explicitly free the `zend_handlers_table` and the `p5s` to
avoid spurious leak reports.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=d756e1db2324c1f4ab6f9b52e329959ce6a02bc3>
[2] <http://git.php.net/?p=php-src.git;a=commit;h=8742276eb3905eb97a585417000c7b8df85006d4>
2020-01-23 11:47:20 +01:00
Nikita Popov
a3e29ba34a Prefer using declaring class rather than direct parent in error
Point to the class that actually declares the property, which is
not necessarily the same as the direct parent class.
2020-01-21 17:19:07 +01:00
Nikita Popov
b0c920f94b Simplify __call fetching for static methods
If we have a __call on a parent, we should always also have a
__call on the child, so there's no need to perform this walk.
2020-01-21 17:04:24 +01:00
Nikita Popov
12fec7a14e Simplify constant updating for properties
Instead of walking up the parent chain, use the scope stored in
the property info. This way we only need to walk one list of
property infos.
2020-01-21 16:29:56 +01:00
Nikita Popov
6811222422 Eliminate uses of ZVAL_ZVAL and friends
Instead add RETURN_COPY(_VALUE) macros will the expected behavior.

RETURN_ZVAL doesn't make any sense since PHP 7, but has stuck
around, probably because the alternative was to write directly to
the return_value variable.
2020-01-20 10:34:17 +01:00
Máté Kocsis
99db00b1f2
Fix #78880 Another round 2020-01-19 18:28:43 +01:00
Tyson Andre
3c72105edb Remove leftover ZEND_CAST code for (unset) cast.
Followup for d74d3922ce

Attempting to require a file with (unset) casts results in an E_COMPILE_ERROR
that can't be caught or handled by set_exception_handler/set_error_handler.

Also remove the (bool) cast, because the ZEND_BOOL opcode handles that.

Remove inference that array -> object cast can throw.
It was added in 2a286ad599 - I don't know how creating an stdClass would throw.
(numeric keys, references, etc. don't cause it to throw)

Closes GH-5042
2020-01-18 11:06:19 -05:00
Máté Kocsis
d1764ca330
Make error messages more consistent by fixing capitalization
Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
2020-01-17 14:52:46 +01:00
Nikita Popov
9ec1ee5976 Add support for deprecating constants
Internal constants can be marked as CONST_DEPRECATED, in which
case accessing them will throw a deprecation warning.

For now this is only supported on global constants, not class
constants. Complain to me if you need to deprecate a class
constant...

Closes GH-5072.
2020-01-17 10:05:06 +01:00
Nikita Popov
bd1977282c Use zend_type inside type lists
Instead of having a completely independent encoding for type list
entries. This is going to use more memory, but I'm not particularly
concerned about that, as type unions that contain multiple classes
should be uncommon. On the other hand, this allows us to treat
top-level types and types inside lists mostly the same.

A new ZEND_TYPE_FOREACH macros allows to transparently treat list
and non-list types the same way. I'm not using it everywhere it could be
used for now, just the places that seemed most obvious.

Of course, this will make any future type system changes much simpler,
as it will not be necessary to duplicate all logic two times.
2020-01-17 09:37:54 +01:00
Christoph M. Becker
1e62e627fd Merge branch 'PHP-7.4'
* PHP-7.4:
  Disable optimizations for ASan instrumented builds
2020-01-16 13:58:28 +01:00
Christoph M. Becker
c9908ee5eb Disable optimizations for ASan instrumented builds
ASan instrumentation does not support the MSVC debug runtime, but still
it does not make sense to enable optimizations for such builds, since
they are not meant for production usage anyway, and although memory
corruption issues are still found in optimized builds, the generated
diagnostics are close to being useless, and apparently sometimes even
outright wrong.  Therefore, we disable all optimizations for ASan
instrumented builds.

We also introduce and use `ZEND_WIN32_NEVER_INLINE` for ASan enabled
builds to avoid inlining of functions, so we get even better
diagnostics.
2020-01-16 13:57:21 +01:00
Máté Kocsis
0b4778c377
Fix #78880: Another bunch of spelling errors 2020-01-16 09:46:47 +01:00
Christoph M. Becker
9d7e03c325 Remove useless skip check
As of PHP 5.4.0, `detect_unicode` is always available, so this check
cannot fail.
2020-01-15 18:38:15 +01:00
George Peter Banyard
9118a96fb0 Remove va_copy from zend_portability as it's always available since C99 2020-01-14 22:56:03 +01:00
Dmitry Stogov
77bf144d52 Inline hot parts of bitwise instructions into hybrid VM 2020-01-14 13:47:10 +03:00
Nikita Popov
dc02e68f77 Try to fix ZTS build 2020-01-13 13:12:55 +01:00
Nikita Popov
d2110e9880 Use helper in one more place 2020-01-13 12:44:16 +01:00
Dmitry Stogov
27815959e1 Improve access to zend_map_ptr data 2020-01-13 14:27:35 +03:00
Nikita Popov
1caf0951a0 Handle one more case I missed 2020-01-13 12:06:23 +01:00
Nikita Popov
5d869df753 Make class name references use the class_name production
Throw a compile error for "static" references instead, where it
isn't already the case.

Also extract the code that does that -- we have quite a few places
where we get a const class ref and require it to be default.
2020-01-13 11:51:09 +01:00
Nikita Popov
2a3e37a496 Don't use yystrlen()
This is unnecessary and not available when GLR is used.
2020-01-13 11:23:30 +01:00