Commit Graph

1910 Commits

Author SHA1 Message Date
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
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
bb54694f4f Fix refcounting 2020-08-24 16:23:19 +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
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
Nikita Popov
8318379dd3 Switch back to FREE_UNFETCHED_OP_DATA
Some of the code paths leading to this do not fetch op data.
Hopefully this fixes the release build failure.
2020-07-09 11:54:08 +02:00
Nikita Popov
5795dfda93 Fix bug #79599 in a different way
Move the emission of the undefined variable notice before the
array separation.
2020-07-09 11:12:44 +02:00
Christoph M. Becker
8483a21f29 Fix several mostly Windows related phpdbg bugs
* Properly initialize PHPDBG_G(watch_tmp)

  Otherwise that may cause segfaults in ZTS builds.

* Deactivate potentially remaining watchpoints after REPL

  Otherwise the memory could still be protected, resulting in segfaults
  during shutdown.

* NULL zend_handlers_table after freeing

  As of commit 4130fe4[1], the `zend_handlers_table` is explicitly
  freed in the `zend_vm_dtor()`.  Since phpdbg (and maybe some other
  SAPIs) may restart the engine afterwards, we have to make sure that
  the table is also NULLed.

* Only set context option if there is a context

  In other words, we must not follow the null pointer.

* Cater to file handles without attached console

  File handles do not necessarily have an attached console (for
  instance, pipes do not), in which case `GetConsoleScreenBufferInfo()`
  fails.  In this case we set a default value (`40`) for lines like on
  other systems.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=4130fe437a5db7ead1444d3748bd0fbad9829cb2>
2020-05-26 17:45:25 +02:00
Nikita Popov
4a08ca1294 Respect typed references in catch assignment
I decided to null out EG(exception) early here, which means only
the exception from the dtor / ref assign is preserved, and the
previous exception is not chained in. This is more robust, and
I don't think this situation is common enough to be bothered about
the precise behavior.
2020-05-26 14:59:40 +02:00
Dmitry Stogov
b2376be81d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  zend_timeout() may access EX(opline)
2020-04-17 14:56:01 +03:00
Dmitry Stogov
d31ccb5fc8 zend_timeout() may access EX(opline) 2020-04-17 14:55:14 +03:00
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
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
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
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
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
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
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
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
Dmitry Stogov
20ef51db22 Fixed bug #78937 (Preloading unlinkable anonymous class can segfault) 2019-12-11 00:46:30 +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
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
b02cf8b66e Merge branch 'PHP-7.3' into PHP-7.4 2019-10-10 11:41:51 +02:00
Nikita Popov
4ba8d78100 Merge branch 'PHP-7.2' into PHP-7.3 2019-10-10 11:41:29 +02:00
Nikita Popov
96c84b7bc1 Fix leak on static method call on non-existent class 2019-10-10 11:40:49 +02:00
Nikita Popov
bea832cbf6 Don't check type of simple parameter default values
After fixing the int->double coercion case, this is already verified
at compile-time, so there is no need to redo this type check on
every call.

Only perform the type check every time for the case of AST default
values.
2019-10-08 17:29:41 +02:00
Nikita Popov
21148679d1 Handle "non well formed" exception during ZPP
Previously if the "non well formed" notice was converted into an
exception we'd still end up executing the function.

Also drop the now unnecessary EG(exception) checks in the engine.

Additionally remote a bogus exception in zend_is_callable: It
should only be writing to error, but not directly throwing.
2019-10-08 17:17:49 +02:00
Nikita Popov
a6c9c7c2b8 Handle resources used as array keys consistently
Resources used as array keys are generally handled by throwing a
notice and converting the resource to the resource handle. The only
exception is the [$resource => null] syntax, where this was treated
as an illegal offset type instead. However, this also only happened
for VM evaluations, the AST evaluator did handle resources correctly.
2019-09-27 10:40:41 +02:00
Dmitry Stogov
23db95e3e5 Fixed GOTO VM 2019-09-26 01:17:54 +03:00
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
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
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
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
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