1
0
mirror of https://github.com/php/php-src.git synced 2026-04-12 10:33:11 +02:00
Commit Graph

3957 Commits

Author SHA1 Message Date
George Peter Banyard
2f1d0f2bc3 Throw directly instead of replacing error handler in ext/date (#6954) 2021-05-07 11:10:39 +01:00
Aaron Piotrowski
779fe8e43a Check current_execute_data instead of flags in fiber destructor
Checking EG(current_exectue_data) throws into the previous fiber instead of triggering a fatal error during shutdown. A fatal error is triggered only if the throwing destroyed fiber was resumed from {main}.
2021-05-05 10:48:30 -05:00
Nikita Popov
fb374f56a7 Rethrow exceptions in fiber destructor
We need to make sure that HANDLE_EXCEPTION is set when the fiber
throws during destruction.

Fixes oss-fuzz #33875.
2021-05-05 12:49:47 +02:00
Nikita Popov
4411026217 Close generator already in dtor phase
In the added test case, the Closure ends up being freed before
the generator during GC.

This patch closes the generator (and thus releases the held
closure / execute_data) already during dtor_obj, which will avoid
ordering issues in free_obj. dtor_obj is not always called, but
if it isn't, then we also won't run GC and will free_obj in
reverse construction order.

Fixes oss-fuzz #33947.
2021-05-04 16:59:59 +02:00
Nikita Popov
2aac616071 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't treat failed assignment as initialization
2021-05-04 14:46:52 +02:00
Nikita Popov
398cfb982e Don't treat failed assignment as initialization
Only reset the uninitialized property flag once the type check
has succeeded. Previously the property was treated as unset rather
than uninitialized after a failed assignment.

Noticed this edge-case while working on accessors...
2021-05-04 14:46:04 +02:00
Aaron Piotrowski
810fb59f66 Improve fiber backtraces
The start/resume/throw execute_data is now attached as the prev_execute_data to the bottom frame of the fiber stack when the fiber is running.
2021-04-30 12:17:50 -05:00
Aaron Piotrowski
4166653298 Fix exception thrown during fiber destruction
Previously an exception thrown during fiber destruction resulted in a fatal error, but that exception should be able to be caught (unless we’ve entered shutdown, then still use a fatal error so the error is not hidden).
2021-04-30 00:26:47 -05:00
Nikita Popov
9a1da9f61f Don't use separate static variables in inherited methods
RFC: https://wiki.php.net/rfc/static_variable_inheritance

Closes GH-6719.
2021-04-28 17:08:50 +02:00
Nikita Popov
3e6b447979 Partially deprecate Serializable
If Serializable is implemented, require that __serialize() and
__unserialize() are implemented as well, else issue a deprecation
warning.

Also deprecate use of PDO::FETCH_SERIALIZE.

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

Closes GH-6494.
2021-04-28 16:55:14 +02:00
Aaron Piotrowski
c276c16b66 Implement Fibers
RFC: https://wiki.php.net/rfc/fibers

Closes GH-6875.
2021-04-26 11:07:06 -05:00
George Peter Banyard
7372a3e117 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Bug #80972: Memory exhaustion on invalid string offset
2021-04-26 13:22:37 +01:00
George Peter Banyard
418fcd22e8 Fix Bug #80972: Memory exhaustion on invalid string offset
Closes GH-6890
2021-04-26 13:21:40 +01:00
Máté Kocsis
30a082cb16 Make some exception properties typed
Closes GH-6891
2021-04-22 10:22:50 +02:00
Nikita Popov
9799cf989c Reset property table for disabled classes
To avoid retaining behavior about property visibility or types.
2021-04-20 10:35:10 +02:00
Dmitry Stogov
08dafda123 Fixed use-after-free introduced by ca49e53670 2021-04-19 18:16:14 +03:00
Matt Brown
6cd0b48cac Implement never return type
The never type can be used to indicate that a function never
returns, for example because it always unwinds.

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

Closes GH-6761.
2021-04-19 11:27:29 +02:00
Nikita Popov
8bb81226c1 Handle debug_print_backtrace() from main script
If there is nothing to print, the smart_str will hold a nullptr.

Fixes oss-fuzz #33334.
2021-04-19 10:20:30 +02:00
twosee
559c3f6d86 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80929
2021-04-16 09:59:01 +08:00
twosee
09f55604ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80929
2021-04-16 09:49:36 +08:00
twosee
c0b1bdcdc3 Fixed bug #80929
The function name should be kept if Closure was created from the function which is marked as ZEND_ACC_CALL_VIA_TRAMPOLINE, because it is not a one-time thing and it may be called multiple times.

Closes GH-6867.
2021-04-16 09:48:36 +08:00
Dmitry Stogov
ca49e53670 Stop inserting fake frames on VM stack.
Now similar "fake" frames now materialized when fetching debug
backtraces. The patch also fixes few incorrect backtraces for generators
in *.phpt tests.
2021-04-15 15:30:10 +03:00
Nikita Popov
7af3a392f1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle ref return from Iterator::key()
2021-04-15 13:06:04 +02:00
Nikita Popov
46f9fed0d8 Handle ref return from Iterator::key()
Handle this in the implementation of get_current_key of user_it,
so that the callers may assume that the key is not a reference.

Fixes oss-fuzz #33018.
2021-04-15 13:05:48 +02:00
Nikita Popov
91908bcd52 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix function/file mixup in backtrace printing
2021-04-13 16:34:17 +02:00
Levi Morrison
6fd13d0afd Fix function/file mixup in backtrace printing
The error says "Function name" is not a string, but it's actually
investigating the "file" field, not "function".

Closes GH-6768.
2021-04-13 16:33:30 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
twosee
d5456baf52 Use zend_throw_unwind_exit() for assert.bail (#6826)
We can use unwind_exit instead of the evil zend_bailout without breaking the original behavior in this way because the original zend_bailout will longjmp out of the executor, so the exception will never be caught and it always triggers the E_ERROR here.
2021-04-13 15:23:36 +08:00
Nikita Popov
6bd46d2f68 Don't use range information from a prototype method
The method may be overridden.
2021-04-12 10:30:04 +02:00
Dmitry Stogov
d8e4fbae62 Fast Class Cache
This is generalization of idea, that was previously usesd for caching
resolution of class_entries in zend_type. Now very similar mechanizm is
used for general zend_string into zend_class_entry resolution.

Interned zend_string with IS_STR_CLASS_NAME_MAP_PTR GC_FLAG uses its
refcount to adress corresponding zend_class_entry cache slot.
The refcount keeps an offset to this slot from CG(map_ptr_base).
Flag may be checked by ZSTR_HAS_CE_CACHE(str), cache slot may be read by
ZSTR_GET_CE_CACHE(str) and set by ZSTR_SET_CE_CACHE(str, ce).
2021-04-08 23:37:40 +03:00
Nikita Popov
5fd2a5b13b Fix handling of unknown class in trait precedence list
Fixes oss-fuzz #31983.
2021-03-19 16:04:47 +01:00
Ilija Tovilo
269c8dac1d Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
Máté Kocsis
495bf5cdd0 Merge branch 'PHP-8.0' 2021-03-06 00:56:47 +01:00
Máté Kocsis
0f8312342f Fix the error message of attribute flag validation 2021-03-06 00:56:25 +01:00
Nikita Popov
056eac6b03 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80811
2021-03-01 16:30:19 +01:00
Nikita Popov
75a4f484f0 Fixed bug #80811
When filling in defaults for skipped params, make sure that
reference parameters get the expected reference wrapper.
2021-03-01 16:30:01 +01:00
Nikita Popov
26c3fa2759 Merge branch 'PHP-8.0'
* PHP-8.0:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:51 +01:00
Nikita Popov
5875bf754e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Always remove HT iterators, even for uninit HT
2021-03-01 16:22:29 +01:00
Nikita Popov
2c508c4d40 Always remove HT iterators, even for uninit HT
Fixes oss-fuzz #31423.
2021-03-01 16:22:11 +01:00
Dmitry Stogov
b0c7ea4919 Change the order of properties used in foreach(), var_dump(), serialize(), comparison, etc. Now properties are ordered according to their layout in zend_object structure. 2021-03-01 13:43:22 +03:00
Nikita Popov
47a2e5c785 Reference dynamic functions through dynamic_defs
Currently, dynamically declared functions and closures are inserted
into the function table under a runtime definition key, and then later
possibly renamed. When opcache is not used and a file containing a
closure is repeatedly included, this leads to a very large memory leak,
as the no longer needed closure declarations will never be freed
(https://bugs.php.net/bug.php?id=76982).

With this patch, dynamic functions are instead stored in a
dynamic_func_defs member on the op_array, which opcodes reference
by index. When the parent op_array is destroyed, the dynamic_func_defs
it contains are also destroyed (unless they are stilled used elsewhere,
e.g. because they have been bound, or are used by a live closure). This
resolves the fundamental part of the leak, though doesn't completely
fix it yet due to some arena allocations.

The main non-obvious change here is to static variable handling:
We can't destroy static_variables_ptr in destroy_op_array, as e.g.
that would clear the static variables in a dynamic function when
the op_array containing it is destroyed. Static variable destruction
is separated out for this reason (we already do static variable
destruction separately for normal functions, so we only need to
handle main scripts).

Closes GH-5595.
2021-03-01 11:35:54 +01:00
Dmitry Stogov
72c3ededed Change the order of properties used for var_dump(), serialize(), comparison, etc.
Now properties are ordered according to their layout in zend_object structure.
2021-03-01 13:29:49 +03:00
Dmitry Stogov
99d0f502dc Fixed error message 2021-02-24 19:12:32 +03:00
Nikita Popov
8e8e0017b9 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix trampoline leak on dynamic static call of non-static method
2021-02-22 10:33:16 +01:00
Nikita Popov
ab98944195 Fix trampoline leak on dynamic static call of non-static method
Fixes oss-fuzz #30317.
2021-02-22 10:32:59 +01:00
Nikita Popov
b3f4a3105c Don't resolve special class names
Adjust zend_resolve_class_name() to not resolve special class names.
This avoids the need to only call this function after a preliminary
check for non-default fetch types. Doing so is somewhat fragile
when dynamic class names are involved.

Fixes oss-fuzz #31139.
2021-02-22 10:11:14 +01:00
Nikita Popov
de03bc8eb7 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80781
2021-02-22 09:38:44 +01:00
Nikita Popov
ed4f90f0c7 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80781
2021-02-22 09:38:34 +01:00
Nikita Popov
6dd85f83f7 Fixed bug #80781
zend_find_array_dim_slow() may throw, make sure to handle this.
This backports the code we already use for this on PHP-8.0,
and also backports an exception check that makes this easier to
catch.
2021-02-22 09:36:43 +01:00
Markus Staab
fd3692ba41 Fix typo [ci skip]
Closes GH-6713.
2021-02-22 09:02:31 +01:00