Commit Graph

781 Commits

Author SHA1 Message Date
Christoph M. Becker
92c4b06513 Use ZEND_UNREACHABLE() instead of ZEND_ASSERT(0)
Instead of marking unreachable code with `ZEND_ASSERT(0)`, we introduce
`ZEND_UNREACHABLE()`, so that MSVC which does not consider `assert(0)`
to mark unreachable code does no longer trigger C4715[1] warnings in
debug builds.  This may be useful for other compilers as well.

[1] <https://docs.microsoft.com/de-de/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4715?view=vs-2019>
2020-06-16 18:39:09 +02:00
Nikita Popov
e56e53a59d Back up fake_scope in zend_call_function
We regularly find new places where we forgot to reset fake_scope.
Instead of having to handle this for each caller of zend_call_function()
and similar APIs, handle it directly in zend_call_function().
2020-06-09 16:33:33 +02:00
twosee
88355dd338 Constify char * arguments of APIs
Closes GH-5676.
2020-06-08 10:38:45 +02:00
Nikita Popov
5b4c4bbe3b Free attribute validators on shutdown 2020-06-05 10:36:35 +02:00
Nikita Popov
975acfe71e Pass zend_string message to zend_error_cb
This makes the zend_error_cb API simpler, and avoid formatting
the same message in multiple places.

It should be noted that the passed zend_string is always
non-persistent, so if you want to store it persistently somewhere,
you may still need to duplicate it.

The last_error_message is cleared a bit more aggressive, to make
sure it doesn't hang around across allocator life-cycles.

Closes GH-5639.
2020-06-05 09:54:02 +02:00
George Peter Banyard
25acc4a6b4 Fix [-Wundef] warning in Zend folder 2020-05-12 22:01:51 +02:00
Nikita Popov
5d93eab620 Don't reset SIGG(running) when calling zend_on_timeout
This is only an internal callback nowadays and does not actually
run any user code. It must be async signal safe.
2020-05-11 15:05:01 +02:00
Nikita Popov
41c7d28c11 Add macro to get ini target address 2020-04-27 10:30:00 +02:00
Nikita Popov
e15409b43c Adjust zend_write_func signature
Make it return size_t instead of int, to line up with actual
implementation.
2020-04-15 11:01:12 +02:00
Dmitry Stogov
78b64bd4ed Merge branch 'PHP-7.4'
* PHP-7.4:
  Check asserts early
  identation fix
  Call global code of preloaded script in global context
  Avoid "Anonymous class wasn't preloaded" error by lazely loading of not preloaded part of a preloaded script
2020-03-13 11:42:07 +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
Máté Kocsis
118b04bd6e
Improve argument error messages in ext/sodium
Closes GH-5197
2020-02-28 18:09:39 +01:00
Nikita Popov
169805777c Merge branch 'PHP-7.4'
* PHP-7.4:
  Apply tidy formatting
2020-02-03 13:42:08 +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
Nikita Popov
dc02e68f77 Try to fix ZTS build 2020-01-13 13:12:55 +01:00
Dmitry Stogov
27815959e1 Improve access to zend_map_ptr data 2020-01-13 14:27:35 +03:00
Nikita Popov
a40a69fdd0 Merge branch 'PHP-7.4'
* PHP-7.4:
  Introduce extra counter to avoid RTD key collisions
2019-12-13 11:05:41 +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
999e32b65a Implement union types
According to RFC: https://wiki.php.net/rfc/union_types_v2

The type representation now makes use of both the pointer payload
and the type mask at the same time. Additionall, zend_type_list is
introduced as a new kind of pointer payload, which is used to store
multiple class types. Each of the class types is a tagged pointer,
which may be either a class name or class entry. The latter is only
used for typed properties, while arguments/returns will instead use
cache slots. A type list can contain a mix of both names and CEs at
the same time, as not all classes may be resolvable.

One thing this is missing is support for union types in arginfo
and stubs, which I want to handle separately.

I've also dropped the special object code from the JIT implementation
for now -- I plan to add this back in a different form at a later time.
For now I did not want to include non-trivial JIT changes together
with large functional changes.

Another possible piece of follow-up work is to implement "iterable"
as an internal alias for "array|Traversable". I believe this will
eliminate quite a few special-cases that had to be implemented.

Closes GH-4838.
2019-11-08 15:15:48 +01:00
Nikita Popov
ac4e0f0852 Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This
is in preparation for union types, where we will be using both at
the same time.

To avoid increasing the size of arginfo structures, the
pass_by_reference and is_variadic fields are now stored as part of
the type_mask (8-bit are reserved for custom use).

Different types of pointer payloads are distinguished based on bits
in the type_mask.
2019-11-08 15:15:48 +01:00
Nikita Popov
db233501ff Use clean shutdown on uncaught exception 2019-10-11 12:41:15 +02:00
Peter Cowburn
bc61997571 add ValueError
ValueError is intended to be thrown when a function or method receives
an argument that has the right type (incorrect type should throw a
TypeError) but an inappropriate value.
2019-09-09 21:06:00 +01:00
Nikita Popov
ea5854ca8c Make error_reporting=E_ALL the default 2019-09-02 10:03:26 +02:00
Nikita Popov
21b0f44429 Merge branch 'PHP-7.4' 2019-07-04 10:32:48 +02:00
Nikita Popov
1fea887cc0 Set PROPERTY_TYPES_RESOLVED flag for internal classes
Also make sure that the resolution happens before preloading runs.
2019-07-04 10:32:36 +02:00
Joe Watkins
d41ab64456
Merge branch 'PHP-7.4'
* PHP-7.4:
  simple ignore arguments in exceptions implementation
2019-07-02 13:19:25 +02:00
Joe Watkins
0819e6dc9b
simple ignore arguments in exceptions implementation 2019-07-02 13:18:39 +02:00
twosee
61f78de486 Constify some char* arguments or return values of ZEND_API
Closes GH-4247.
2019-06-12 16:49:32 +02:00
Dmitry Stogov
b4a3b49eab Merge branch 'PHP-7.4'
* PHP-7.4:
  Better hot/cold code splitting
2019-05-31 12:22:08 +03:00
Dmitry Stogov
1df9f238fe Better hot/cold code splitting 2019-05-31 12:20:21 +03:00
Nikita Popov
785f034e41 Merge branch 'PHP-7.4' 2019-04-12 12:04:11 +02:00
Nikita Popov
ce408504d5 Mark zend_bailout() as a noreturn function 2019-04-12 10:41:53 +02:00
Nikita Popov
6d71d983da Merge branch 'PHP-7.4' 2019-03-27 13:05:04 +01:00
Nikita Popov
d1e5006c14 Fix lineno for more inheritance errors
And also include explicit linenos in tests.
2019-03-27 13:02:28 +01:00
Nikita Popov
d49371fbd4 Merge branch 'PHP-7.4' 2019-03-26 15:48:02 +01:00
Nikita Popov
0122f395c7 Add zend_error_at API that accepts a filename and lineno
Use this for the opcache preloading warnings, as an example usage.
2019-03-26 15:47:00 +01:00
Dmitry Stogov
2dd2dcaf9c Merge branch 'PHP-7.4'
* PHP-7.4:
  Implemented a faster way to access predefined TSRM resources - CG(), EG(), etc.
2019-03-14 03:02:10 +03:00
Dmitry Stogov
9499484ed2 Implemented a faster way to access predefined TSRM resources - CG(), EG(), etc. 2019-03-14 03:01:01 +03:00
Dmitry Stogov
dbb462db5d Merge branch 'PHP-7.4'
* PHP-7.4:
  Avoid reinitailization of ZTS cache pointer. Initialize it once in TSRM.c
2019-03-12 17:36:02 +03:00
Dmitry Stogov
04b67bac32 Avoid reinitailization of ZTS cache pointer. Initialize it once in TSRM.c 2019-03-12 17:35:50 +03:00
Nikita Popov
513b76794b Make zpp failures always throw, independent of strict_types
Previously zend_parse_parameters (and FastZPP) would handle invalid
arguments depending on strict_types: With strict_types=1, a TypeError
is thrown, with strict_types=0 a warning is thrown and (usually) NULL
is returned. Additionally, some functions (constructors always and
other methods sometimes) opt-it to throwing regardless of strict_types.

This commit changes zpp to always generate a TypeError exception in
PHP 8.
2019-03-11 11:32:20 +01:00
Joe Watkins
bf21727ea0
Merge branch 'PHP-7.4'
* PHP-7.4:
  drop unused parameter from zend_startup
2019-03-11 10:10:45 +01:00
Joe Watkins
df6e9fae8f
drop unused parameter from zend_startup 2019-03-11 10:10:14 +01:00
Nikita Popov
6130e56356 Merge branch 'PHP-7.4' 2019-02-28 17:24:13 +01:00
Nikita Popov
ff315098f4 Free map_base_ptr during post_startup 2019-02-28 17:23:18 +01:00
Nikita Popov
13b94dbb60 Merge branch 'PHP-7.4' 2019-02-28 16:15:13 +01:00
Nikita Popov
89a7b7cc96 Fix leak in resolve_property_types
We need to free the original string as well, not just the lowercased
one.
2019-02-28 16:14:56 +01:00
Peter Kokot
18295b396f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix typos in code comments in Zend/ [skip ci]
2019-02-18 17:56:38 +01:00
Tyson Andre
da3316ff0f Fix typos in code comments in Zend/ [skip ci] 2019-02-18 17:56:28 +01:00
Nikita Popov
68ed34005c Merge branch 'PHP-7.4' 2019-02-15 13:04:24 +01:00