Commit Graph

14796 Commits

Author SHA1 Message Date
Dmitry Stogov
c5159b3832 Check asserts early 2020-03-12 22:26:30 +03:00
Dmitry Stogov
2dddab01ae Avoid "Anonymous class wasn't preloaded" error by lazely loading of not preloaded part of a preloaded script 2020-03-12 16:31:24 +03:00
Christoph M. Becker
a72b261db5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79364: When copy empty array, next key is unspecified
2020-03-11 08:55:28 +01:00
Christoph M. Becker
2462f2dab1 Fix #79364: When copy empty array, next key is unspecified
We must not forget to keep the `nNextFreeElement` when duplicating
empty arrays.
2020-03-11 08:54:05 +01:00
Nikita Popov
760faa12b2 Fixed bug #79357
Peculiarly, for once the cause was not SOAPs "interesting" error
handling, but a bug in the call trampoline for internal functions...
2020-03-09 15:01:31 +01:00
Nikita Popov
c3ab8fd3f8 Add test for bug #63816
This has been fixed in PHP 7.4, add a test for it.
2020-03-06 11:16:47 +01:00
Christoph M. Becker
9dda3b9eb2 Next is 7.3.17 2020-03-03 10:19:31 +01:00
Nikita Popov
533633deda Remove generated lexer
Accidentially committed this when merging from 7.3.
2020-02-28 17:25:47 +01:00
Nikita Popov
375191aae7 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #79062
2020-02-28 17:07:36 +01:00
Nikita Popov
6c48da9a50 Fixed bug #79062
Back up the doc comment when performing heredoc scanahead.
2020-02-28 17:06:05 +01:00
Dmitry Stogov
d9f56903ad Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed incorrect behavior of internal memory debugger
2020-02-27 12:27:58 +03:00
Dmitry Stogov
45b4368d5c Fixed incorrect behavior of internal memory debugger 2020-02-27 12:27:22 +03:00
Nikita Popov
8c8f8c4193 Add test for bug #60161
This has been fixed in PHP 7.4, let's make sure it stays fixed.
2020-02-26 16:48:03 +01:00
Nikita Popov
1e50c81f6f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #63206: Fully support error/exception_handler stacking, even with null or inside the handler
2020-02-25 12:44:11 +01:00
Mark Plomer
8c6a7c3326 Fix #63206: Fully support error/exception_handler stacking, even with null or inside the handler
Always push the current user_error/exception_handler to the stack,
even when it is empty, so restore_error_handler() always works as
expected.

The user_error_handler is especially temporarily empty when we are inside
the error handler, which caused inconsistent behaviour before.
2020-02-25 12:43:42 +01:00
Nikita Popov
5a5680c25b Don't use asm arithmetic under msan
Clang 9 supports asm goto, so these no longer get automatically
skipped.

(cherry picked from commit 33bf1495b2)
2020-02-21 11:58:52 +01:00
Xinchen Hui
6295ff77b7 Fixed bug #79244 (php crashes during parsing INI file). (Laruence)
Cherry-picked the fix(not sure why this wasn't merged to 7.4) for:
Fixed bug #77589 (Core dump using parse_ini_string with numeric sections)

Section name should not be typed(NULL, FALSE, TRUE etc)

Conflicts:

	Zend/zend_ini_scanner.c
2020-02-10 13:01:51 +08:00
Dmitry Stogov
5d0ef4c239 Make opcodes to return de-refereced values of typed references (in the same was as for non-typed) 2020-02-06 15:48:54 +03:00
Christoph M. Becker
e3632fdc0d Next is 7.3.16 2020-02-04 11:38:29 +01:00
Nikita Popov
58b17906f5 Apply tidy formatting
Mostly reindent PHP scripts to spaces.
2020-02-03 13:41:31 +01:00
Nikita Popov
27fb0b28dd Add WHITESPACE_SENSITIVE run-tests section
This is used to indicate that the test should not be changed by
automated formatting changes.
2020-02-03 10:08:15 +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
Dmitry Stogov
db7193f31e Fixed bug #79094 (Crashing when running recursion function) 2020-01-31 10:34:04 +03: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
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
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
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
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
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
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
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
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
Christoph M. Becker
38c0a53b60 Bump version 2020-01-07 11:03:19 +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
003be875e4 Make url_stats in resolve_path quiet
These stats are used to check whether the file exists -- they
should not generate errors. Having the flag set is particularly
important for custom stream wrappers.
2019-12-30 23:22:26 +01:00
Christoph M. Becker
98df5c97f4 Avoid undefined behavior 2019-12-30 23:17:39 +01:00
Nikita Popov
f77747b06c Properly propagate url_stat exceptions during include
Make sure we abort operations early, and that we don't emit
additional warnings or errors if an exception has been thrown.
2019-12-30 22:56:42 +01:00
Xinchen Hui
f09b958e90 Similar problem (#79022) also exists in Interfaces 2019-12-24 14:20:55 +08:00
Xinchen Hui
153c9cc346 Fixed bug #79022 (class_exists returns True for classes that are not ready to be used) 2019-12-24 14:04:19 +08:00
Nikita Popov
b829ea5f74 Fix leak when generator closed during yield in finally
In this case we need to free any pending exceptions or return values
that will be discarded.
2019-12-20 17:46:31 +01:00
Nikita Popov
885b3451f4 Fix early free of assign_obj op_data
We need to make sure that op_data is only freed after populating
result, as op_data may be the only thing holding the value in the
case of an overloaded assignment.

This reverts the code to how it looked like in 7.3.
2019-12-20 10:35:34 +01:00
Dmitry Stogov
66d5b0608a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78999 (Cycle leak when using function result as temporary)
2019-12-19 23:17:39 +03:00
Dmitry Stogov
eb846939b1 Fixed bug #78999 (Cycle leak when using function result as temporary) 2019-12-19 23:11:08 +03:00
Nikita Popov
527ad1d80c Avoid signed integer overflow in string offset check
Cast to size_t before performing operations instead of afterwards.
2019-12-19 11:47:50 +01:00
Nikita Popov
e4b12fc62a Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Add destructor annotations in ini parser
2019-12-19 10:43:14 +01:00
Nikita Popov
0f078f6e78 Add destructor annotations in ini parser
It would be better to switch this to use %union and %type annotations,
but not going to do that change for 7.3.
2019-12-19 10:43:05 +01:00
Nikita Popov
df08d6bffe Fix leak in assign_ref with function
As far as I can see, the retval copying is already done in all
callers of this function, so it should not be duplicated here.
2019-12-18 17:18:10 +01:00
Nikita Popov
4a61d842e7 Fixed bug #78776
By using the normal inheritance check if the parent is abstract
as well.
2019-12-18 15:55:45 +01:00
Nikita Popov
bfb38c3592 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Rethrow generator exception even without active stack frame
2019-12-18 11:04:46 +01:00
Nikita Popov
897d99c7a4 Rethrow generator exception even without active stack frame
Finally blocks in generators may be invoked during shutdown, in
which case we don't have a stack frame. Similar to what
zend_call_function does, we still need to rethrow these exceptions,
otherwise they will be hidden (and leak).
2019-12-18 11:04:15 +01:00
Nikita Popov
b965f158ac Fix use-after-free when trying to write to closure property 2019-12-18 10:24:02 +01:00
Nikita Popov
ee89e73312 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix freeing of dynamic call name
2019-12-18 10:11:23 +01:00
Nikita Popov
189f625e2b Fix freeing of dynamic call name
We need to free op2 if the call construction fails.

Also remove a redundant check for !call.
2019-12-18 10:11:09 +01:00
Nikita Popov
0301ab70b3 Fix const/cv freeing on failed reference assignment 2019-12-18 09:54:10 +01:00
Dmitry Stogov
d89cd0bb22 Property names of internal classes from temporary extensins, loaded by dl(), may be emalloc-ed strings. 2019-12-17 10:10:11 +03:00
Dmitry Stogov
abf05181b9 Fixed memory leak 2019-12-17 10:09:22 +03:00
Dmitry Stogov
0927af3d8d Fixed memory leaks 2019-12-17 09:58:27 +03:00
Nikita Popov
77e131da91 Set opcache.optimization_level=0 in test
Otherwise opcache "inlines" the function, which causes a minor
difference in destruction behavior.
2019-12-16 20:23:17 +01:00
Stanislav Malyshev
d82a2f6c21 Test fixes 2019-12-16 10:31:22 -08:00
Nikita Popov
11b041d3c6 Fixed bug #78973
Save opline in leave helper to correctly handle destructor calls
during CV freeing (or other leave freeing).
2019-12-16 18:52:30 +01:00
Nikita Popov
7e9e0937f3 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78921
2019-12-13 16:38:24 +01:00
Nikita Popov
621598eaa8 Fixed bug #78921
By resetting fake_scope during autoloading. We already do the same
when executing destructors.
2019-12-13 16:37:20 +01:00
Nikita Popov
0f2cdbf214 Introduce extra counter to avoid RTD key collisions
Also generate a fatal error if a collision occurs in zend_compile.

This is not perfect, because collisions might still be introduced
via opcache, if one file is included multiple times during a request,
invalidate in the meantime and recompiled by different processes.

This still needs to be addressed, but this patch fixes the much
more common case of collisions occuring when opcache is not used.

Fixes bug #78903.
2019-12-13 11:04:44 +01:00
Nikita Popov
be89a5c7f1 Fixed bug #78950: Preloading trait method with static variables
We need to make sure that trait methods with static variables
allocate a separate MAP slot for the static variables pointer,
rather than working in-place.
2019-12-12 11:52:43 +01:00
Nikita Popov
502cd7b1f1 Revert "Fixed bug #78903: Conflict in RTD key for closures results in crash"
This reverts commit b55033fa18.

This breaks ext/opcache/tests/bug65915.phpt.
2019-12-11 14:38:48 +01:00
Nikita Popov
b55033fa18 Fixed bug #78903: Conflict in RTD key for closures results in crash
I wasn't able to create a simple reproducer for this. General approach
is the same as for anonymous classes: If the key is already used, reuse
the old definition.
2019-12-11 13:07:45 +01:00
Dmitry Stogov
3280209c03 Addirional fix for bug #78918 2019-12-11 12:21:49 +03:00
Dmitry Stogov
20ef51db22 Fixed bug #78937 (Preloading unlinkable anonymous class can segfault) 2019-12-11 00:46:30 +03:00
Nikita Popov
3f86adb0ef Fixed bug #78935: Check that all linked classes can be preloaded
During preloading, check that all classes that have been included
as part of the preload script itself (rather than through opcache_compile_file)
can actually be preloaded, i.e. satisfy Windows restrictions, have
resolved initializers and resolved property types. When resolving
initializers and property types, also autoload additional classes.
Because of this, the resolution runs in a loop.
2019-12-10 13:05:48 +01:00
Nikita Popov
8d36d79d57 Fix build 2019-12-09 16:06:26 +01:00
Dmitry Stogov
03d1c788ea Export zend_init_func_run_time_cache() 2019-12-09 15:58:00 +03:00
Dmitry Stogov
92c23e1fd3 Call zend_unregister_ini_entries() when unload extension loaded through dl() without MSHUTDOWN callback.
Extensions with MSHUTDOWN should use UNREGISTER_INI_ENTRIES().
2019-12-09 15:05:24 +03:00
Nikita Popov
32c1f37574 Fixed bug #78926: Handle class table reallocation on failed link
When we change back the bucket key on a class linking failure,
make sure to reload the bucket pointer, as the class table may
have been reallocated in the meantime.

Also remove a bogus bucket key change in anon class registration:
We don't actually rename the class in this case anymore, the RTD
key is already the final name.
2019-12-09 09:15:27 +01:00
Nikita Popov
5fcc12f505 Use unmangled named in property type inheritance error 2019-12-09 08:48:33 +01:00
Nikita Popov
84354c62b3 Fixed bug #78904: Don't call any magic for uninitialized typed properties
We already changed the behavior for __set() in f1848a4. However, it
seems that this is also a problem for all the other property magic,
see bug #78904.

This commit makes the behavior of all the property magic consistent:
Magic will not be triggered for uninitialized typed properties, only
explicitly unset() ones. This brings behavior more in line how
non-typed properties behave and avoids WTF.

Closes GH-4974.
2019-12-09 08:40:53 +01:00
Nikita Popov
07fc0764d1 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix constant evaluation of && and ||
2019-12-06 11:10:31 +01:00
Nikita Popov
249e49092d Fix constant evaluation of && and ||
The "return" in the for loop should have been a break on the switch,
otherwise the result is just ignored... but because it prevents
evaluation of the other operand, it also violates the invariant that
everything has been constant evaluated, resulting in an assertion
failure.

The for loop isn't correct in any case though, because it's not legal
to determine the result based on just the second operand, as the
first one may have a side-effect that cannot be optimized away.
2019-12-06 11:07:57 +01:00
Nikita Popov
3167e591b5 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix AST printing of nullable builtin types
2019-12-04 11:21:28 +01:00
Nikita Popov
fac43d6515 Fix AST printing of nullable builtin types
Fixes oss-fuzz #19109.
2019-12-04 11:20:52 +01:00
Nikita Popov
6540797f1e Fixed bug #78898 2019-12-04 09:40:48 +01:00
Christoph M. Becker
65bbc67063 Next is 7.3.14 2019-12-03 12:04:17 +01:00
Dmitry Stogov
2ebf530946 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value)
2019-11-25 14:09:18 +03:00
Dmitry Stogov
bb30fe9e2b Fixed bug #78868 (Calling __autoload() with incorrect EG(fake_scope) value) 2019-11-25 14:05:43 +03:00
Tyson Andre
b037fe5bd1 Handle reallocated root buffer during GC destroy phase (v2)
We no longer protect GC during the destroy phase, so we need to
deal with buffer reallocation.

Note that the implementation of spl_SplObjectStorage_free_storage
will call the destructor of SplObjectStorage, and free the instance properties,
which I think is what caused the root buffer to be reallocated.
(`current` is a pointer for an index within the root buffer?)

This fixes bug #78811 for me.

Closes GH-4935
2019-11-23 10:45:20 -05:00
Dmitry Stogov
be6fb13873 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix $x = (bool)$x; for undefined with opcache
2019-11-18 11:27:43 +03:00
Dmitry Stogov
e72e3370c6 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix $x = (bool)$x; for undefined with opcache
2019-11-18 11:26:30 +03:00
Tyson Andre
a2c41c0ea6 Fix $x = (bool)$x; for undefined with opcache
And `$x = !$x`

Noticed while working on GH-4912

The included test would not emit undefined variable errors in php 8.0
with opcache enabled. The command used:

```
php -d zend_extension=opcache.so --no-php-ini -d error_reporting=E_ALL \
    -d opcache.file_cache= -d opcache.enable_cli=1  test.php
```
2019-11-18 11:24:03 +03:00
Nikita Popov
3f4a15113c Handle reallocated root buffer during GC destroy phase
We no longer protect GC during the destroy phase, so we need to
deal with buffer reallocation.

Possible fix for bug #78811.
2019-11-15 15:53:49 +01:00
Derick Rethans
51ac4e302c Zend Engine version is no longer in -dev 2019-11-15 14:27:20 +00:00
Nikita Popov
266f3a02bc Fixed bug #78810 2019-11-15 12:06:17 +01:00
Dmitry Stogov
c3f23642da ws 2019-11-12 10:51:55 +03:00
Nikita Popov
dacadf5aa3 Disable ifunc resolvers under thread sanitizer as well 2019-11-07 13:08:03 +01:00
Nikita Popov
a3e454aacc Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78787
2019-11-06 12:53:21 +01:00
Nikita Popov
6d4965febd Fixed bug #78787
Not the first time inheritance of shadow properties causes an issue,
thankfully this whole concept is gone in PHP 7.4.
2019-11-06 12:52:34 +01:00
Christoph M. Becker
4c9ba3e042 7.3.13 is next 2019-11-05 18:20:56 +01:00
Nikita Popov
451314111b Revert "Remove configure checks for supported instruction sets"
This reverts commit edccf32f7f.

This was reported to cause issues for as yet unknown reasons in
bug #78769. As this was intended as code cleanup, revert this from
7.4 at least. May reapply it to master later.
2019-11-04 11:32:46 +01:00
Nikita Popov
944c1cf034 Fixed bug #78768
Remove the typedef from zend_types.h, use explicit struct prefix
instead.
2019-11-01 17:04:15 +01:00
Nikita Popov
edccf32f7f Remove configure checks for supported instruction sets
These were checking whether the instruction set is supported by
the host CPU, however they were only used to condition on whether
this instruction set is targeted at all. It would still use dynamic
dispatch (e.g. based on ifunc resolvers) to select the actual
implementation. Whether the target is guaranteed to support the
instruction set without dispatch is determined based on pre-defined
macros like __SSE2__.

This removes the configure-time builtin cpu checks to remove
confusion. Additionally this allows targeting an architecture that
is newer than the host architecture.
2019-10-31 11:27:53 +01:00