This issue was introduced in GH-15021. When building the call graph, we can now
see preloaded functions. However, building the call graph involves adding the
function to the caller list of the callee, which we don't want to do for
functions not coming from the script.
Fixes GH-15490
Currently, internal classes are registered with the following code:
INIT_CLASS_ENTRY(ce, "InternalClass", class_InternalClass_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ...;
This has worked well so far, except if InternalClass is readonly. It is because some inheritance checks are run by zend_register_internal_class_ex before ZEND_ACC_READONLY_CLASS is added to ce_flags.
The issue is fixed by adding a zend_register_internal_class_with_flags() zend API function that stubs can use from now on. This function makes sure to add the flags before running any checks. Since the new API is not available in lower PHP versions, gen_stub.php has to keep support for the existing API for PHP 8.3 and below.
The libproc.h header file was added on Solaris as of 11.4.
* Also add guard check to the entire function
* When libproc.h isn't available also sys/procfs.h is redundant
* Move the <sys/lwp.h> out of the guard
* Exclude more stuff from Solaris 10
On Solaris 10 and GCC 4.9 check failed with error in config.log:
error: missing binary operator before token "("
The __has_builtin must be checked in its own `#ifdef/defined` line
above the `#if __has_builtin(....` usage.
As is, MSVC uses `__vectorcall`, but clang uses `__cdecl`. This
obviously is bad for interoperability (and causes link issues), and is
likely worse for FFI which offers some limited (but likely sufficient
for our purposes) support for `__vectorcall` on Windows.
Since clang claims to support `__vectorcall` as of 3.6.0, and we bumped
the requirements to clang 4.0.0 already, there shouldn't be any issues.
Follow up on 13483
As previously reported in https://github.com/php/php-src/pull/13483#discussion_r1718546927:
> The parameter names seem to be incorrect.
>
> It should be `$status`, not `$code`.
>
> The RFC explicitly uses that parameter name in the proposal: https://wiki.php.net/rfc/exit-as-function#proposal
>
> It is also the name already used in the [manual](https://www.php.net/exit).
>
> Lastly, the parameter name `$status` better covers what can be passed: either a status _message_ or a status _code_.
> While `$code` would read pretty weird when passing a message:
> ```php
> exit(code: 'message');
> ```
This commit attempts to fix this.
Includes adding a test for exit/die using a named argument.
Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
Previously, seen symbols were never cleaned during the compilation of a single
file. This makes it impossible to use a class or function from a different
namespace if such a symbol is also declared within the same file. This is
inconsistent with how it would work when split into different files.
YIELD and YIELD_FROM increment opline before returning, but in most places
we need the opline to point to the YIELD and YIELD_FROM.
Here I change YIELD / YIELD_FROM to not increment opline. This simplifies the
code and fixes GH-15275 in a better way.
Closes GH-15328
The optimization flags are removed in configure.ac when using the
'--enable-debug' configure option (which also adds the '-O0'). When
using '--enable-debug-assertions' option, the optimization flags ideally
shouldn't be removed and this case never actually happen because the
CFLAGS at this point in ZEND_INIT contain all sorts of other flags also,
so it's redundant as it never gets executed.
Closes GH-15305
- Autoconf sets the GCC variable to either "yes" if GNU C compatible
compiler is detected (like gcc or clang) or to an empty value
otherwise.
- AX_CHECK_COMPILE_FLAG arguments quoted and empty arguments trimmed
* hash: Add SSE2 implementation of SHA-256
Implementation taken from
tarsnap/libcperciva@661752aee8.
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
* zend_cpuinfo: Add ZEND_CPU_FEATURE_SHA
* hash: Add SHA-NI implementation of SHA-256
Implementation taken from
tarsnap/libcperciva@661752aee8.
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
* NEWS / UPGRADING
---------
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
`try` is a keyword in C++, and as such C++ code including <zend_enum.h>
fails to compile unless a workaround is in place. To resolve this, we
simply rename the parameter.
We choose `try_from` to make it clear that this parameter is true when
the function is called from `BackedEnum::tryFrom()`. For consistency,
we also rename the `try` parameter of `zend_enum_from_base()`, although
that function is not exported.
This issue had been reported by @oplanre, who also provided an initial
PR.
Closes GH-15259.
PHP 8.4 is supposed to be built with vs17 (aka. Visual Studio 2022)[1],
so we also do this for CI.
We mark gh8841.phpt as xfail for known reasons.
[1] <https://windows.php.net/>
- The ZTS is defined on only one place
- Added help text for ZTS preprocessor macro
- The 'enable_zts' variable replaced with PHP_THREAD_SAFETY in
configure.ac.
- Nits fixed.
This flag was never necessary. We know a static variable is uninitialized (i.e.
the initializer has never been called) iff the zval in the static variable array
does not contain a reference.
Prompted by a related issue in ext-uopz reported by Christoph.
This replaces the AC_MSG_ERROR with AC_MSG_FAILURE, where appropriate.
The AC_MSG_ERROR outputs given message and exits the configure step. The
AC_MSG_FAILURE does the same but also automatically outputs additional
message "See 'config.log' for more details." which might help directing
the user where to look further.
The AC_MSG_ERROR is used for errors where current test step isn't logged
in the config.log and wouldn't make sense, and AC_MSG_FAILURE is mostly
used in cases of library checks, compilation tests, headers checked with
AC_CHECK_HEADER* and similar tests that are also logged in the
config.log.
AC_MSG_ERROR([Sanity check failed.]) output:
```
configure: error: Sanity check failed.
```
AC_MSG_FAILURE([Sanity check failed.]) output:
```
configure: error: in '/path/to/php-src':
configure: error: Sanity check failed.
See 'config.log' for more details
```
* Allow optimizer to depend on preloaded symbols
It is safe for the optimizer to rely on preloaded symbols. This can occur when
compiling non-preloaded files, referencing preloaded ones.
* Disable inline pass for observer test
* Move duplicated code into functions
* Add comment to specific optimization value
* Optimizer should only rely on preloaded symbols in the symbol table
* Fix skipif for windows
The destructor of generators is a no-op when the generator is running in a fiber,
because the fiber may resume the generator. Normally the destructor
is not called in this case, but this can happen during shutdown.
We detect that a generator is running in a fiber with the
ZEND_GENERATOR_IN_FIBER flag.
This change fixes two cases not handled by this mechanism:
- The ZEND_GENERATOR_IN_FIBER flag was not added when resuming a "yield from $nonGenerator"
- When a generator that is running in a fiber has multiple children (aka multiple generators yielding from it), all of them could be considered to also run in a fiber (only one actually is), and could leak if not destroyed before shutdown.
This prevents compilation error when compiling PHP by GCC with "-O2 -g -Wall -Werror"
zend_API.c:2754:34: error: array subscript ‘zend_function
{aka const union _zend_function}[0]’ is partly outside array bounds of
‘unsigned char[160]’ [-Werror=array-bounds=]
2754 | if (ZSTR_VAL(fptr->common.function_name)[0] != '_'
Instead of fixing up temporaries count in between observer steps, just apply the additional temporary in the two affected observer steps.
Closes GH-14018.
I don't understand the rationale of fatal erroring here. It seems this should
properly unprotect the compared elements when returning up the stack.
Related to GH-14980
The zend_object.properties HashTable needs to be built just in time by calling
rebuild_object_properties() on the object before accessing it. Normally this is
done automatically in zend_std_get_properties(), but we do it manually in a few
places.
In this change I introduce an inline variant of zend_std_build_properties(), and
refactor these places to use it instead of calling rebuild_object_properties()
manually.
rebuild_object_properties() renamed as rebuild_object_properties_internal(), to
enforce usage of zend_std_get_properties() or zend_std_build_properties_ex().
Closes GH-14996
* zend build making sigjmp_buf and api check as mandatory.
all unixes support it since long time, the few which don't do not meet
the requirements to build php anyway (minix, dietlibc, ...).
$obj->ro[] = 42;, passByRef($obj->ro); and the likes should emit an indirect
modification error message. This message already existed but was used
inconsistently.