Commit Graph

2130 Commits

Author SHA1 Message Date
Nikita Popov
cd1c36f772 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #80049
2020-09-03 17:13:47 +02:00
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
Dmitry Stogov
0d157cf526 Micro-optimization 2020-09-02 17:31:48 +03:00
Levi Morrison
66c3e900e2 Add zend_observer API
Closes GH-5857.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
Co-authored-by: Sammy Powers <sammyk@datadoghq.com>
2020-09-01 09:59:59 -06:00
Nikita Popov
48e31be7a3 Fix FE_FETCH_R_SIMPLE specialization
After a99d08b5d1 the type can
include UNDEF. However, UNDEF can only reach FE_FREE, not FE_FETCH.
As such, simply ignore this type.
2020-09-01 14:43:06 +02:00
Nikita Popov
927771333b Fix unused variable warning 2020-08-28 17:19:32 +02:00
Nikita Popov
b2bc2c62fa Remove unnecessary cache_slot arguments
zend_verify_type_error_common() no longer needs the cache_slot,
so drop it there and from all users.
2020-08-28 17:15:09 +02:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
Nikita Popov
86cd009718 Fix pass by ref error for named params 2020-08-26 15:10:08 +02:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Nikita Popov
795ad1e354 Fix memory leak on unknown named param in iterator unpack 2020-08-26 12:19:17 +02:00
Nikita Popov
1003ae2692 Fix passing of undef var to named arg
This needs to use the previously computed argument target.
2020-08-26 11:53:02 +02:00
Nikita Popov
492621f99e Fix memory leak on unknown named param 2020-08-26 11:44:15 +02:00
Nikita Popov
d7d2b060e1 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix memory leak when yielding from non-iterable
2020-08-26 11:32:56 +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
779e904465 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix refcounting
2020-08-24 16:23:33 +02:00
Nikita Popov
bb54694f4f Fix refcounting 2020-08-24 16:23:19 +02:00
Christoph M. Becker
5643f34a1e Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix #79979: passing value to by-ref param via CUFA crashes
2020-08-24 15:03:26 +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
Dmitry Stogov
5c18ee58b9 Fixed use-after-free introduced by aed1f78515 2020-08-24 09:50:54 +03:00
Dmitry Stogov
aed1f78515 micro-optimization 2020-08-20 15:02:12 +03:00
Nikita Popov
42eda5160d SAVE_OPLINE in NULL_HANDLER
Let's avoid crashing before the nice error message gets printed...
2020-08-11 15:14:50 +02:00
Nikita Popov
f491dabe40 Fix nullsafe operator on reference
Dereference the value before checking the type. As the happy path
necessarily has to check for references, I'm not bothering to
delay the comparison.
2020-08-11 15:11:36 +02:00
Nikita Popov
74c4381806 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79947
2020-08-10 10:13:34 +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
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Nikita Popov
a6e63b42c3 Make check in RECV_VARIADIC more precise
Fetch arg_info only once (it's always the same one...) and check
ZEND_TYPE_IS_SET on it, rather than checking if *any* parameter
has a type.
2020-07-31 12:02:28 +02:00
Ilija Tovilo
9bf119832d
Implement nullsafe ?-> operator
RFC: https://wiki.php.net/rfc/nullsafe_operator

Closes GH-5619.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-07-24 10:05:03 +02:00
Nikita Popov
213852de78 Fixed bug #79828 2020-07-13 09:55:13 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Nikita Popov
6556846754 Fixed bug #79818
Only destroy the variable directly before reassigning it. The
value could be read in the meantime.
2020-07-10 14:36:50 +02:00
Ilija Tovilo
9fa1d13301
Implement match expression
RFC: https://wiki.php.net/rfc/match_expression_v2

Closes GH-5371.
2020-07-09 23:52:17 +02:00
Nikita Popov
613a56d1cb Remove FREE_UNFETCHED concept
In master normal FREE_OPs work like FREE_UNFETCHED_OP used to, so
there is no point in keeping this distinction anymore, it's just
confusing.
2020-07-09 11:58:33 +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
04b17217b4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #79599 in a different way
  Revert "Fixed bug #97599 (coredump in set_error_handler)"
2020-07-09 11:18:03 +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
Nikita Popov
5d0687e895 Assert exception set in HANDLE_EXCEPTION()
Some code paths were checking this manually, but we can turn this
into a general assertion to avoid surprises (functions returning
failure without throwing).
2020-07-07 11:31:05 +02:00
Nikita Popov
fb91611276 Remove #undefs from vm_gen
Possibly these were needed for VM_EXPORT, but they don't serve a
purpose now.
2020-07-07 11:25:28 +02:00
Nikita Popov
49396f817a Fixed bug #79777 2020-07-04 09:59:42 +02:00
Nikita Popov
75a04eac97 Make exit() unwind properly
exit() is now internally implemented by throwing an exception,
performing a normal stack unwind and a clean shutdown. This ensures
that no persistent resource leaks occur.

The exception is internal, cannot be caught and does not result in
the execution of finally blocks. This may be relaxed in the future.

Closes GH-5768.
2020-06-29 15:50:12 +02:00
Dmitry Stogov
bb3d4456ee Change GC_COLLECTABLE flag into GC_NOT_COLLECTABLE to simplify GC_MAY_LEAK() check 2020-06-15 14:26:22 +03: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
Max Semenik
23ee4d4b57 Support catching exceptions without capturing them to variables
RFC: https://wiki.php.net/rfc/non-capturing_catches

Closes GH-5345.
2020-05-26 15:12:18 +02:00
Nikita Popov
1203bbf07e Merge branch 'PHP-7.4'
* PHP-7.4:
  Respect typed references in catch assignment
2020-05-26 15:03:26 +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
Nikita Popov
81c824f41f Clarify ZEND_CATCH code
UNDEF the opcode result instead of addref'ing the exception.
2020-05-26 11:34:07 +02:00
Christoph M. Becker
a582931f42 Revert "Revert "Merge branch 'PHP-7.4'""
This reverts commit 28e650a, which reverted commit 046dcfb, which had
to be reverted due to phpdbg issues.  The culprit was that we did not
properly reset `zend_handler_table` to `NULL`, which is required for
SAPIs which may restart the engine after shutdown.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=28e650abf8097a28789a005e5028fee095359583>
[2] <http://git.php.net/?p=php-src.git;a=commit;h=046dcfb531e242d36a7af2942b9b148290c3c7fe>
2020-05-20 14:11:42 +02:00
Máté Kocsis
1179686f62
Improve error messages for invalid property access
Closes GH-5446
Co-authored-by:  Nikita Popov <nikita.ppv@gmail.com>
2020-05-18 08:27:00 +02:00