Commit Graph

458 Commits

Author SHA1 Message Date
Niels Dossche
4c189ae585
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix test expectation for PHP 8.3+
2024-11-25 20:33:26 +01:00
Niels Dossche
ec9a606e5d
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix test expectation for PHP 8.3+
2024-11-25 20:33:20 +01:00
Niels Dossche
ff95138e38
Fix test expectation for PHP 8.3+ 2024-11-25 20:33:14 +01:00
Niels Dossche
5e9273ad0a
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16908: _ZendTestMagicCallForward does not handle references well
2024-11-25 19:39:06 +01:00
Niels Dossche
43a3bd0608
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16908: _ZendTestMagicCallForward does not handle references well
2024-11-25 19:39:01 +01:00
Niels Dossche
d9fada4a71
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16908: _ZendTestMagicCallForward does not handle references well
2024-11-25 19:38:50 +01:00
Niels Dossche
99f5653ebb
Fix GH-16908: _ZendTestMagicCallForward does not handle references well
This testing code was never meant to be used this way, but fixing this
will at least stop fuzzers from complaining about this, so might still
be worthwhile.

Closes GH-16919.
2024-11-25 19:38:33 +01:00
Ilija Tovilo
06b99c059e
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix compiler warning in zend_test
2024-11-05 16:52:00 +01:00
Arnaud Le Blanc
8d30ed4f80
Fix compiler warning in zend_test
Closes GH-16650
2024-11-05 16:51:43 +01:00
Niels Dossche
64f2d11e38
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16628: FPM logs are getting corrupted with this log statement
  Fix GH-16601: Memory leak in Reflection constructors
2024-11-02 19:39:00 +01:00
Niels Dossche
bfd9e0cca3
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16628: FPM logs are getting corrupted with this log statement
  Fix GH-16601: Memory leak in Reflection constructors
2024-11-02 19:38:54 +01:00
Niels Dossche
16cda10650
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16628: FPM logs are getting corrupted with this log statement
  Fix GH-16601: Memory leak in Reflection constructors
2024-11-02 19:37:28 +01:00
Niels Dossche
e643129bbb
Fix GH-16628: FPM logs are getting corrupted with this log statement
zlog_buf_prefix() can return a larger length than what actually was
written due to its use of snprintf(). The code in
zlog_stream_prefix_ex() does not take this into account, other callers
do. What ends up happening then is that stream->length is set to the
length as if snprintf() was able to write all bytes, causing
stream->length to become larger than stream->buf.size, causing a
segfault.

In case the buffer was too small we try with a larger buffer up to a
limit of zlog_limit. This makes sure that the stream length will remain
bounded by the buffer size.

This also adds assertions to make the programmer intent clear and catch
this more easily in debug builds.

Closes GH-16680.
2024-11-02 19:36:20 +01:00
Christoph M. Becker
836a162089
Don't fiddle with NDEBUG in C code (GH-16511)
* Don't fiddle with NDEBUG in C code

It is way to late to do this in php.h, since assert.h has already been
included.  Even pushing that down to zend_portability.h may not have
the desired effect.  Instead we define or undefine NDEBUG as CFLAG, so
that it works in all circumstances.

As a last resort we fail at build time, if `NDEBUG` is defined when
`ZEND_DEBUG` is enabled.

We also remove the useless workaround in zend_test to include assert.h
again, since that usually won't have any effect anyway.

Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2024-10-27 18:20:59 +01:00
Ilija Tovilo
e05b56fdb1
Merge branch 'PHP-8.4'
* PHP-8.4:
  [skip ci] Fix overwritten observer ini setting for gh16514.phpt
2024-10-22 15:21:31 +02:00
Ilija Tovilo
0c297bab21
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  [skip ci] Fix overwritten observer ini setting for gh16514.phpt
2024-10-22 15:21:26 +02:00
Ilija Tovilo
a6bf2f591a
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Fix overwritten observer ini setting for gh16514.phpt
2024-10-22 15:21:20 +02:00
Ilija Tovilo
c5c4c3be44
[skip ci] Fix overwritten observer ini setting for gh16514.phpt 2024-10-22 15:20:56 +02:00
Ilija Tovilo
178ee5b879
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix handling of nested generator in zend_test observer
2024-10-22 14:52:19 +02:00
Ilija Tovilo
289f59ad48
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix handling of nested generator in zend_test observer
2024-10-22 14:52:07 +02:00
Ilija Tovilo
ce99adeb54
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix handling of nested generator in zend_test observer
2024-10-22 14:51:58 +02:00
Ilija Tovilo
69bcbdc3c5
Fix handling of nested generator in zend_test observer
This is the counterpart of GH-15952.

Fixes GH-16514
Closes GH-16530
2024-10-22 14:51:36 +02:00
Christoph M. Becker
50acf5eb15
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16266: _ZendTestClass::test() segfaults on named parameter
2024-10-21 19:46:34 +02:00
Christoph M. Becker
241e3e0e27
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16266: _ZendTestClass::test() segfaults on named parameter
2024-10-21 19:46:02 +02:00
Christoph M. Becker
713c71adbd
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16266: _ZendTestClass::test() segfaults on named parameter
2024-10-21 19:44:34 +02:00
Christoph M. Becker
b73bcaa47c
Fix GH-16266: _ZendTestClass::test() segfaults on named parameter
We need to assign the proper number of arguments.

Closes GH-16271.
2024-10-21 19:43:33 +02:00
Christoph M. Becker
01aeaf2e95
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16414: zend_test.observer.observe_function_names may segfault
2024-10-20 12:11:42 +02:00
Christoph M. Becker
909cecb7fa
Fix GH-16414: zend_test.observer.observe_function_names may segfault
Unless `zend_test.observer.enabled` is on, we must not add observer
handlers, so we let the INI modify handler fail early.

We also need to ensure that the functions to observe have already been
called, so that their begin and end handlers are properly initialized.
Otherwise we will not observe the function execution, but a segfault.

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>

Closes GH-16438.
2024-10-20 12:11:08 +02:00
Tim Düsterhus
3401d55726
zend_weakrefs: Add zend_weakrefs_hash_(clean|destroy)() (#16439)
These are equivalent to `zend_hash_clean()` and `zend_hash_destroy()`
respectively, but take care of correctly unregistering the weak references to
the keys.

This addition rounds off the weakmap functionality added in
471102edcd by taking one possible footgun away
from the user.
2024-10-14 18:57:08 +02:00
Ilija Tovilo
253f4af90e
[skip ci] Fix new closure dump syntax in test 2024-10-14 15:03:53 +02:00
Ilija Tovilo
e7dc0d2c40
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix segfault on debug_backtrace() in _ZendTestFiber
2024-10-14 14:05:21 +02:00
Ilija Tovilo
94bd6ca080
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix segfault on debug_backtrace() in _ZendTestFiber
2024-10-14 14:05:13 +02:00
Ilija Tovilo
5955ce8987
Fix segfault on debug_backtrace() in _ZendTestFiber
Fixes GH-16230
Closes GH-16299
2024-10-14 14:04:49 +02:00
Ilija Tovilo
7d99355dad
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix segfault in zend_test_execute_internal()
2024-10-14 14:03:09 +02:00
Ilija Tovilo
0237361679
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix segfault in zend_test_execute_internal()
2024-10-14 14:03:01 +02:00
Ilija Tovilo
5c798415cd
Fix segfault in zend_test_execute_internal()
zend_pass_function also has no name, so we might also be referring to an
internal function here. In this case, ZEND_NEW uses the zend_pass_function when
there is no constructor.

Fixes GH-16294
Closes GH-16301
2024-10-14 14:02:36 +02:00
Christoph M. Becker
8a5c716eb8
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16388: UB when freeing a cloned _ZendTestFiber
2024-10-12 22:49:45 +02:00
Christoph M. Becker
41d75f42ec
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16388: UB when freeing a cloned _ZendTestFiber
2024-10-12 22:48:46 +02:00
Christoph M. Becker
a3eb1fd86d
Fix GH-16388: UB when freeing a cloned _ZendTestFiber
Since there is no need to clone instances of this test class, we
prevent cloning in the first place.

Closes GH-16400.
2024-10-12 22:48:11 +02:00
Niels Dossche
b24cc7386b
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline
2024-10-07 17:18:32 +02:00
Niels Dossche
0338008852
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline
2024-10-07 17:17:27 +02:00
Niels Dossche
e715dd0afb
Fixed GH-16233: Observer segfault when calling user function in internal function via trampoline
In the test, I have an internal `__call` function for `_ZendTestMagicCallForward` that calls the global function with name `$name` via `call_user_function`.
Note that observer writes the pointer to the previously observed frame in the last temporary of the new call frame (`*prev_observed_frame`).

The following happens:
First, we call `$test->callee`, this will be handled via a trampoline with T=2 for the two arguments. The call frame is allocated at this point. This call frame is not observed because it has `ZEND_ACC_CALL_VIA_TRAMPOLINE` set. Next we use `ZEND_CALL_TRAMPOLINE` to call the trampoline, this reuses the stack frame allocated earlier with T=2, but this time it is observed. The pointer to the previous frame is written outside of the call frame because `T` is too small (should be 3). We are now in the internal function `_ZendTestMagicCallForward::__call` where we call the global function `callee`. This will push a new call frame which will overlap `*prev_observed_frame`. This value gets overwritten by `zend_init_func_execute_data` when `EX(opline)` is set because `*prev_observed_frame` overlaps with `EX(opline)`. From now on, `*prev_observed_frame` is corrupted. When `zend_observer_fcall_end` is called this will result in reading wrong value `*prev_observed_frame` into `current_observed_frame`. This causes issues in `zend_observer_fcall_end_all` leading to the segfault we observe.

Despite function with `ZEND_ACC_CALL_VIA_TRAMPOLINE` not being observed, the reuse of call frames makes problems when `T` is not large enough.
To fix this, we make sure to add 1 to `T` if `ZEND_OBSERVER_ENABLED` is true.

Closes GH-16252.
2024-10-07 17:16:43 +02:00
Niels Dossche
589da5b008
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add SKIPIF for ZendMM for observer_fiber_functions_03.phpt
2024-10-06 18:00:49 +02:00
Niels Dossche
bd8495ef93
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add SKIPIF for ZendMM for observer_fiber_functions_03.phpt
2024-10-06 18:00:43 +02:00
Niels Dossche
fbb1001d84
Add SKIPIF for ZendMM for observer_fiber_functions_03.phpt
This test uses memory_limit, so it fails when using USE_ZEND_ALLOC=0.
2024-10-06 18:00:33 +02:00
Niels Dossche
9f0138babe
Merge branch 'PHP-8.3'
* PHP-8.3:
  Update test for changed error message format in libxml 2.13
2024-09-12 23:11:28 +02:00
Niels Dossche
6f975a271f
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Update test for changed error message format in libxml 2.13
2024-09-12 23:11:23 +02:00
Niels Dossche
3354cc6e89
Update test for changed error message format in libxml 2.13 2024-09-12 23:11:14 +02:00
DanielEScherzer
5dd0575698
Generated arginfo header files: combine preprocessor conditional blocks (#15736)
When functions' or class methods' availability is based on some preprocessor
condition, the generated arginfo header files wrap the declarations in the
preprocessor `#if` conditional blocks, one per declaration, even if they are in
the same conditional block based on comments in the stub file. Instead of
having multiple conditional blocks one after the other with the same condition,
combine them into a single conditional block.
2024-09-04 13:04:22 +02:00
DanielEScherzer
53cb89670c
Generated arginfo header files: remove empty zend_function_entry arrays (#15705)
When a class (or enum) has no methods, rather than using an array that only
contains `ZEND_FE_END`, use `NULL` for the functions. The implementation of
class registration for internal classes, `do_register_internal_class()` in
zend_API.c, already skips classes where the functions are `NULL`. By removing
these unneeded arrays, we can reduce the size of the header files, while also
removing an unneeded call to zend_register_functions() for each internal class
with no extra methods.
2024-09-03 23:19:53 +02:00