Commit Graph

15454 Commits

Author SHA1 Message Date
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
Nikita Popov
7ce531f2c2 Make constant() error handling consistent with plain const lookup
This means we get an Error exception and a much better error
message indicating the root cause (e.g. accessing a private class
constant).
2020-01-10 13:39:56 +01:00
Nikita Popov
0a2f6c5527 Move undefined constant error into get_constant_ex
All the other error conditions are already handled in there, so
this one should be as well.
2020-01-10 11:48:10 +01:00
Nikita Popov
d0d1654a34 Fix #49555: Improve "function must be a string" error message
Be more specific for the individual cases and provide relevant
type information.
2020-01-08 14:32:11 +01:00
Nikita Popov
33476ec301 Refer to method rather than function name in error message 2020-01-08 14:26:27 +01:00
Nikita Popov
ae5d7604f6 Fix #65274: Add class name to undef class constant error 2020-01-08 14:18:14 +01:00
George Peter Banyard
bfe3f934a3 Add warning and convert to exception in string offset assignment:
Convert the empty string assignment to an Error as per RFC [1]
Add a warning that only the first byte will be assigned to the offset if provided
a needle that is longer than one byte.

[1] https://wiki.php.net/rfc/engine_warnings
2020-01-07 21:54:42 +01:00
Nikita Popov
1e4920c119 Renumber zval types, clarify allowed overlap
Make it clear that types used for type declarations can overlap
with the rest, and can also overlap in MAY_BE space.

This makes things more robust against the addition of new primitive
types.
2020-01-07 14:55:52 +01:00
Tyson Andre
37a7046d85 Merge branch 'identical-handler' into HEAD 2020-01-03 19:04:20 -05:00
Máté Kocsis
8f4f1dea34
Convert zend_parse_parameters_none() to fast ZPP
I've done the conversion in those extensions where fast ZPP is predominant.
2020-01-03 13:23:37 +01:00
Nikita Popov
0e6cff70a5 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add test for bug #73816
2020-01-03 11:27:27 +01:00
Nikita Popov
6f63e05320 Add test for bug #73816
This has been fixed by 0f2cdbf214,
add the test case.
2020-01-03 11:26:31 +01:00
Nikita Popov
d8c9902567 Implement WeakMap
RFC: https://wiki.php.net/rfc/weak_maps
2020-01-03 10:43:24 +01:00
Máté Kocsis
1b93cfee0c
Use RETURN_THROWS() after zend_parse_method_parameters() 2020-01-02 23:01:37 +01:00