Commit Graph

19077 Commits

Author SHA1 Message Date
Peter Kokot
84a0da1574
Sync #if/ifdef/defined (#14508)
This syncs CPP macro conditions:
- _WIN32
- _WIN64
- HAVE_ALLOCA_H
- HAVE_ALPHASORT
- HAVE_ARPA_INET_H
- HAVE_CONFIG_H
- HAVE_DIRENT_H
- HAVE_DLFCN_H
- HAVE_GETTIMEOFDAY
- HAVE_LIBDL
- HAVE_POLL_H
- HAVE_PWD_H
- HAVE_SCANDIR
- HAVE_SYS_FILE_H
- HAVE_SYS_PARAM_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_TIME_H
- HAVE_SYS_TYPES_H
- HAVE_SYS_WAIT_H
- HAVE_UNISTD_H
- PHP_WIN32
- ZEND_WIN32

These are either undefined or defined to 1 in Autotools and Windows.

Follow up of GH-5526 (-Wundef).
2024-06-09 14:23:41 +02:00
Gina Peter Banyard
86a4fa3d02 Zend/Optimizer: Fix some [-Wsign-compare] warnings 2024-06-08 17:15:01 +01:00
Gina Peter Banyard
51379d66ec
Zend: Add object_init_with_constructor() API (#14440)
This will instantiate the object and execute its constructor with the given parameters.
2024-06-06 21:21:16 +01:00
Gina Peter Banyard
3869a67468
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix bug GH-14456: Attempting to initialize class with private constructor calls destructor
2024-06-06 15:51:47 +01:00
Gina Peter Banyard
7bab3a3a80
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix bug GH-14456: Attempting to initialize class with private constructor calls destructor
2024-06-06 15:51:34 +01:00
Gina Peter Banyard
cdb7677b38
Fix bug GH-14456: Attempting to initialize class with private constructor calls destructor
Closes GH-14469
2024-06-06 15:50:41 +01:00
Dmitry Stogov
924e7fcb8a
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484)
2024-06-05 23:59:49 +03:00
Dmitry Stogov
ee7d35cc4d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484)
2024-06-05 23:59:37 +03:00
Dmitry Stogov
86b93bc479
Fix GH-14480: Method visibility issue introduced in version 8.3.8 (#14484) 2024-06-05 23:53:31 +03:00
Niels Dossche
a3b148e38d
Fix GH-14361: Deep recursion in zend_cfg.c causes segfault
Changes the CFG reachability algorithm to use iteration instead of
recursion.

Closes GH-14432.
2024-06-05 17:43:51 +02:00
Tim Düsterhus
7c2a4dbd72
Replace ZEND_ASSUME() by ZEND_ASSERT() in zend_hash_*_ptr setters (#14466)
I had a case where I was intentionally storing a `NULL` pointer within a
HashTable to mark an entry as “blocked”, without paying for the overhead of
checking the entry type when reading the pointer, resulting in semantics that
are similar to using `isset()` instead of `array_key_exists()` in userland.

This worked fine in unoptimized test builds, but due to the `ZEND_ASSUME()` in
the `zend_hash_find_ptr` functions, the optimized release builds turned the
logic of:

    my_pointer = zend_hash_find_ptr(ht, key);
    if (my_pointer == NULL) {
        return;
    }
    *my_pointer;

into

    zv = zend_hash_find(ht, key);
    if (zv) {
        *Z_PTR_P(zv);
    } else {
        return;
    }

thus introducing a hard-to-debug and compiler-dependent crash when the entry
exists, but the stored pointer is `NULL`.

Change the `ZEND_ASSUME()` in the setters to `ZEND_ASSERT()`. This would have
made my mistake immediately obvious in debug builds when storing the pointer.
The getters still use `ZEND_ASSUME()` under the assumption that they are called
much more often, reducing the impact on debug builds: Assuming the developer
uses the `_ptr` variants for both reading and writing the entries, the mistake
will be reliably caught during writing, making the assert during reading
unnecessary.

For release builds the `ZEND_ASSERT()` will be equivalent to `ZEND_ASSUME()`,
avoiding any performance impact for those.
2024-06-05 11:08:11 +02:00
Peter Kokot
75033c01c3
Wrap Zend stack limit check in AC_CACHE_CHECK (#14437)
The php_cv_have_stack_limit cache variable enables cross-compiling edge
cases to override the check manually.
2024-06-02 20:13:00 +02:00
Bob Weinand
5fe799a4c6 Merge branch 'PHP-8.3' 2024-06-01 02:42:49 +02:00
Bob Weinand
d98586b6ed Merge branch 'PHP-8.2' into PHP-8.3 2024-06-01 02:41:39 +02:00
Bob Weinand
be7f3aa474 Fix GH-14387: Crash when stack walking in destructor of yielded from values during Generator->throw() 2024-06-01 02:38:55 +02:00
Arnaud Le Blanc
44c199ce6b
random: Make php_random_bytes() useable early during engine startup (#14291)
php_random_bytes() can now be used before RANDOM_G() is initialized
2024-05-30 17:24:34 +02:00
Arnaud Le Blanc
1ab4520c30
Add zend_atomic_int (#14242)
Extend the zend_atomic API for ints. Also add `zend_atomic_*_compare_exchange()`, `ZEND_ATOMIC_*_INITIALIZER()`.
2024-05-30 12:53:44 +02:00
Arnaud Le Blanc
7c5d6557e1
Merge branch 'PHP-8.3'
* PHP-8.3:
  Use ITIMER_REAL for timeout handling on MacOS / Apple Silicon system
2024-05-28 15:27:32 +02:00
Arnaud Le Blanc
3b2764bc76
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Use ITIMER_REAL for timeout handling on MacOS / Apple Silicon system
2024-05-28 15:26:53 +02:00
Manuel Kress
272da51bfd
Use ITIMER_REAL for timeout handling on MacOS / Apple Silicon system
setitimer(ITIMER_PROF) fires too early on MacOS 14 when running on Apple
Silicon. See https://openradar.appspot.com/radar?id=5583058442911744.

Fixes GH-12814
Closes GH-13567
2024-05-28 15:25:46 +02:00
Valentin Udaltsov
b6b16a1758
[RFC] Implement dereferencable for new exprs with constructor args
https://wiki.php.net/rfc/new_without_parentheses

Closes GH-13029
2024-05-28 00:23:12 +02:00
Levi Morrison
c461b60060
refactor: change zend_is_true to return bool (#14301)
Previously this returned `int`. Many functions actually take advantage
of the fact this returns exactly 0 or 1. For instance,
`main/streams/xp_socket.c` does:

    sockopts |= STREAM_SOCKOP_IPV6_V6ONLY_ENABLED * zend_is_true(tmpzval);

And `Zend/zend_compile.c` does:

    child = &ast->child[2 - zend_is_true(zend_ast_get_zval(ast->child[0]))];

I changed a few places trivially from `int` to `bool`, but there are
still many places such as the object handlers which return `int` that
should eventually be `bool`.
2024-05-24 15:16:36 -06:00
Ilija Tovilo
2c91b7364b
Also use zval_get_double for op1 in pow comp time check
Mostly for consistency, but this will also allow evaluating more expressions at
compile time.
2024-05-22 16:30:03 +02:00
Jorg Sowa
23afe57f01
Added deprecation Division by zero when using power with zero as base and negative exponent
RFC: https://wiki.php.net/rfc/raising_zero_to_power_of_negative_number

Closes GH-13128
2024-05-22 15:05:47 +02:00
Cristian Rodríguez
8e62e2b829
Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Pierrick Charron
c69c84a5f6
PHP-8.2 is now for PHP 8.2.21-dev 2024-05-21 14:32:07 -04:00
Eric Mann
eb7a574a8d
PHP-8.3 is now for PHP 8.3.9-dev 2024-05-21 07:48:56 -07:00
divinity76
dabafc7b8e
bool "must" be used instead. (#14287) 2024-05-21 13:10:44 +02:00
Ilija Tovilo
62ebe822de
Separate internal and user function extension handles
This allows us to skip zend_init_internal_run_time_cache() when opcache is
enabled. This function can be quite expensive.

Closes GH-14252
2024-05-21 11:56:38 +02:00
Tim Düsterhus
8094bd1b58
Make ReflectionGenerator::getFunction() legal after generator termination (#14167)
* Make `ReflectionGenerator::getFunction()` legal after generator termination

* Expose the generator function name via `Generator::__debugInfo()`

* Allow creating `ReflectionGenerator` after termination

* Reorder `struct _zend_generator` to avoid a hole

* Adjust `ext/reflection/tests/028.phpt`

This is legal now.

* Fix Generator Closure collection

* Add test to verify the Closure dies with the generator

* NEWS / UPGRADING
2024-05-21 08:54:51 +02:00
Ilija Tovilo
6335264c07
Fix header errors when parsed standalone (#14272)
This is annoying for multiple reasons:

1. LSPs can show many errors for these files.
2. LSP can stop parsing these files completely if there are too many errors,
   resulting in spotty LSP features.
2024-05-20 22:30:38 +02:00
Peter Kokot
52767343b2
Reduce unused variable warnings in config.log (#14264)
This reduces -Wunused-variable and -Wunused-but-set-variable warnings
generated in the Autoconf's config.log to comply with possible stricter
default compiler configuration on the system to avoid having false
results.
2024-05-18 18:28:20 +02:00
Tim Düsterhus
c2a9166ef0
Merge branch 'PHP-8.3'
* PHP-8.3:
  Make the `fcc` parameter `const` in `zend_call_known_fcc` (#14259)
2024-05-17 16:14:45 +02:00
Tim Düsterhus
a89d22cc0c
Make the fcc parameter const in zend_call_known_fcc (#14259)
This makes it legal to call the function from a caller that only has a `const`
pointer to the `fcc` to prevent accidental modification.
2024-05-17 16:14:16 +02:00
Máté Kocsis
2097237da5
Migrate ext/dba resources to objects (#14239)
Related to https://wiki.php.net/rfc/resource_to_object_conversion and https://github.com/php/php-tasks/issues/6
2024-05-17 08:43:33 +02:00
Tim Düsterhus
4988816126
Use zend_call_known_function() to call #[\SensitiveParameter]’s constructor (#14254)
`zend_call_method_with_1_params()` causes needless overhead, due to the
capability of looking up the function by name. It’s also very rarely used (only
in ext/spl).

`zend_call_known_function()` is the standard methodology to call a known
function and going through `Z_OBJCE_P()` avoids the repeated hardcoding of the
CE name.
2024-05-16 23:23:55 +02:00
Ilija Tovilo
600d591cae
Omit FETCH_THIS in closures
Non-static closures are guaranteed to have $this. The existing comment
highlights this, but fails to handle it correctly.

Closes GH-14181
2024-05-16 12:28:11 +02:00
Tim Düsterhus
c90c4fe553
Add zend_get_attribute_object() (#14161)
* Add `zend_get_attribute_object()`

This makes the implementation for `ReflectionAttribute::newInstance()`
reusable.

* Add test for the stack trace behavior of ReflectionAttribute::newInstance()

This test ensures that the `filename` parameter for the fake stack frame is
functional. Without it, the stack trace would show `[internal function]` for
frame `#0`.

* Fix return type of `call_attribute_constructor`
2024-05-14 08:39:43 +02:00
David Carlier
19c8a10f3f
ext/pcntl: add pcntl_getcpu support for solaris.
using getcpuid having similar signature too.

close GH-14188
2024-05-11 05:53:10 +01:00
Saki Takamachi
90c5b2a43b
Merge branch 'PHP-8.3'
* PHP-8.3:
  Cast the parameter type of arm BLOCKCONV_LOAD (#14159)
2024-05-07 19:44:32 +09:00
SakiTakamachi
85371ec49c
Cast the parameter type of arm BLOCKCONV_LOAD (#14159)
When building with gcc in the Arm environment, a runtime error due to an
overflow occurred, so we fixed it.

closes #14159
2024-05-07 19:44:01 +09:00
Dmitry Stogov
c5982c961d
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix incorrect inheritance of private trait methods (#14163)
2024-05-07 13:20:00 +03:00
Dmitry Stogov
da5b43f3a1
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix incorrect inheritance of private trait methods (#14163)
2024-05-07 13:19:49 +03:00
Dmitry Stogov
7a9e0fb39b
Fix incorrect inheritance of private trait methods (#14163)
The bug was introduced in c6b75f9328
2024-05-07 13:16:23 +03:00
Dmitry Stogov
3fcf6ffbc4
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix prototype for trait methods (#14148)
2024-05-06 21:46:13 +03:00
Dmitry Stogov
c42f48d58d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix prototype for trait methods (#14148)
2024-05-06 21:46:00 +03:00
Dmitry Stogov
c6b75f9328
Fix prototype for trait methods (#14148)
* Fix prototype for trait methods

Fixes GH-14009

* Clenup do_inheritance_check_on_method()

Remove wierd checks and define the behavior by explicit set of flags

* Fix naming and indentation

---------

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2024-05-06 21:39:30 +03:00
Ilija Tovilo
9b387ac69a
Remove now empty attribute validator 2024-05-06 13:02:25 +02:00
Ilija Tovilo
bb8de67da5
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix attribute test on newer branches
2024-05-06 13:01:12 +02:00
Ilija Tovilo
5aa5080ea7
Fix attribute test on newer branches 2024-05-06 13:00:47 +02:00