Commit Graph

247 Commits

Author SHA1 Message Date
Jakub Zelenka
6d33a1ab70
Merge branch 'PHP-8.1' into PHP-8.2 2023-04-16 10:55:02 +01:00
Jakub Zelenka
84be9042f9
Add missing zend_test_crash message initialization 2023-04-16 10:54:39 +01:00
Jakub Zelenka
9a20f43b94
Merge branch 'PHP-8.1' into PHP-8.2 2023-04-15 21:29:11 +01:00
Jakub Zelenka
0ac55e9bfb
Add zend_test_crash funtion to segfault PHP process
This is useful for testing PHP-FPM handling of crashed children.

Closes GH-11082
2023-04-15 21:25:02 +01:00
Bob Weinand
ce2000d9be Merge branch 'PHP-8.1' of github.com:php/php-src into PHP-8.2 2023-03-13 12:39:15 +01:00
Bob Weinand
1015f1ff61 Add test, fix x86 JIT
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2023-03-13 12:36:59 +01:00
Derick Rethans
a45bef0ac6 Merge branch 'PHP-8.1' into PHP-8.2 2023-03-09 13:37:19 +00:00
Derick Rethans
aead0c8059 Fixed strict zpp arginfo test 2023-03-09 12:20:56 +00:00
Derick Rethans
f8891f2861 Fixed strict zpp arginfo test 2023-03-09 11:40:47 +00:00
Derick Rethans
8a9b80cfe0 Add test case 2023-03-09 11:40:45 +00:00
Niels Dossche
7682868dd1 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-8065: opcache.consistency_checks > 0 causes segfaults in PHP >= 8.1.5 in fpm context
  Fix GH-8646: Memory leak PHP FPM 8.1
2023-03-07 20:26:57 +01:00
Niels Dossche
ff62d117a3 Fix GH-8646: Memory leak PHP FPM 8.1
Fixes GH-8646
See https://github.com/php/php-src/issues/8646 for thorough discussion.

Interned strings that hold class entries can get a corresponding slot in map_ptr for the CE cache.
map_ptr works like a bump allocator: there is a counter which increases to allocate the next slot in the map.

For class name strings in non-opcache we have:
  - on startup: permanent + interned
  - on request: interned
For class name strings in opcache we have:
  - on startup: permanent + interned
  - on request: either not interned at all, which we can ignore because they won't get a CE cache entry
                or they were already permanent + interned
                or we get a new permanent + interned string in the opcache persistence code

Notice that the map_ptr layout always has the permanent strings first, and the request strings after.
In non-opcache, a request string may get a slot in map_ptr, and that interned request string
gets destroyed at the end of the request. The corresponding map_ptr slot can thereafter never be used again.
This causes map_ptr to keep reallocating to larger and larger sizes.

We solve it as follows:
We can check whether we had any interned request strings, which only happens in non-opcache.
If we have any, we reset map_ptr to the last permanent string.
We can't lose any permanent strings because of map_ptr's layout.

Closes GH-10783.
2023-03-07 20:16:17 +01:00
Ilija Tovilo
2b5aac9303
Fix unescaped {TMP} variables in tests
On Windows {TMP} can return ~, which will result in a parse error
2023-03-01 13:24:39 +01:00
SATO Kentaro
7fccdf72a4
Add support for generating namespaced constant
Closes GH-10552
2023-02-23 10:05:30 +01:00
Arnaud Le Blanc
10f2378584 Fix concurrent testing 2023-02-10 13:31:57 +01:00
Niels Dossche
b4db690cb3
Fix GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range (#10440)
copy_file_range can return early without copying all the data. This is
legal behaviour and worked properly, unless the mmap fallback was used.
The mmap fallback would read too much data into the destination,
corrupting the destination file. Furthermore, if the mmap fallback would
fail and have to fallback to the regular file copying mechanism, a
similar issue would occur because both maxlen and haveread are modified.
Furthermore, there was a mmap-resource in one of the failure paths of
the mmap fallback code.
This patch fixes these issues. This also adds regression tests using the
new copy_file_range early-return simulation added in the previous
commit.
2023-02-10 13:08:44 +01:00
Ilija Tovilo
09f071e63b
Disable opcache file_cache for observer preloading test 2022-11-11 19:33:32 +01:00
Ilija Tovilo
12e2610594
[skip ci] Skip preloading test on Windows 2022-11-09 20:22:10 +01:00
Bob Weinand
4052bbf0e3 Fix opcache preload with observers enabled
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-11-09 16:36:28 +01:00
Martin Schröder
fdd088fc81
Properly deal with internal attributes used on promoted properties.
Closes GH-9661
2022-11-03 14:29:22 +01:00
Bob Weinand
8e49d7f32f Delay releasing closures until after observer end 2022-11-02 16:55:13 +01:00
Bob Weinand
4935e10fc8 Fix hardcoded paths in test 2022-11-02 16:02:16 +01:00
Bob Weinand
b30448f48f Fix observing inherited internal functions
Fixes GH-9871
2022-11-02 15:33:04 +01:00
Florian Sowade
8dabbda8bc Don’t reset func in zend_closure_internal_handler
The pointer is used in _zend_observe_fcall_begin().
2022-11-02 11:46:43 +01:00
Florian Sowade
56c121cea2 Initialize run time cache in PDO methods (#9818)
Without the memset the memory was uninitialized and the new test segfaulted when accessing the memory in _zend_observe_fcall_begin().
2022-10-26 12:21:41 +02:00
Máté Kocsis
e4f2376919
Improve string class constant code generation (#9577)
Using strlen() will make sure that non-constant values can also be used.
2022-09-26 23:12:34 +02:00
Ilija Tovilo
6622c54c53
Fix class link observer with file_cache_only=1
Previously, notify would only get called on classes with CE_CACHE.
However, during compilation class names are non-permanent which won't
get a CE_CACHE and thus wouldn't not get notified.

Closes GH-9550
2022-09-16 14:15:05 +02:00
Bob Weinand
a01dd9feda Revert "Port all internally used classes to use default_object_handlers"
This reverts commit 94ee4f9834.

The commit was a bit too late to be included in PHP 8.2 RC1. Given it's a massive ABI break, we decide to postpone the change to PHP 8.3.
2022-09-14 11:13:23 +02:00
George Peter Banyard
3e362f51ac Add zend_string INI validators
Currently we only have validators for char* which is rather annoying as INI settings are saved as zend_string* in the first place

Closes GH-9328
2022-09-06 10:41:47 +01:00
Máté Kocsis
c547fc183c
Add support for validation of missing class synopses (#9472) 2022-09-05 14:21:15 +02:00
Bob Weinand
94ee4f9834 Port all internally used classes to use default_object_handlers
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
Máté Kocsis
8d78dce902
Remove unused ext/zend_test alias functions 2022-08-30 11:57:29 +02:00
Máté Kocsis
869ab3c481
Adjust PHPDoc 2022-08-30 11:56:29 +02:00
Máté Kocsis
ef21bbe66c
Fix zend/test aliases 2022-08-30 11:48:12 +02:00
Andreas Braun
f7d42f646b
Update gen_stub to avoid compile errors on duplicate function names
Closes GH-9406
2022-08-30 11:33:45 +02:00
Máté Kocsis
b4ec3e9bc0
Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Bob Weinand
bf427b732a Add an API to observe functions and classes being linked
To observe when the functions and classes start being officially available to the user

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-23 15:22:22 +02:00
Bob Weinand
da94baf31a Add proper handling to observe functions in fibers
The current_observed_frame is carried along the fiber context and thus always correct now.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-04 17:16:27 +02:00
Bob Weinand
b3b21ed558 Fix ZEND_RC_DEBUG build in zend_test observer tests 2022-07-31 14:32:35 +00:00
Bob Weinand
50a3fa49b6 Fix observer test 2022-07-31 14:02:48 +00:00
Bob Weinand
625f164963 Include internal functions in the observer API
There are two main motivations to this:
a) The logic for handling internal and userland observation can be unified.
b) Unwinding of observed functions on a bailout does notably not include observers. Even if users of observers were to ensure such handling themselves, it would be impossible to retain the relative ordering - either the user has to unwind all internal observed frames before the automatic unwinding (zend_observer_fcall_end_all) or afterwards, but not properly interleaved.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-07-30 19:20:55 +02:00
Bob Weinand
ac31e2e611 Fix memory_leak in zend_test
Properly use globals init/shutdown to allocate the observer_observe_function_names hashtable instead of attempting to do everything in the ini changed handler
2022-07-30 15:57:08 +00:00
Máté Kocsis
668dbaf6ab
Declare the TestInterface::DUMMY constant in stub 2022-07-30 15:03:48 +02:00
Bob Weinand
9e2de4c2d9 Add an API to manipulate observers at runtime
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-07-29 13:48:05 +02:00
Andreas Braun
3c016467c7
Escape \U and \u in generated stubs
This fixes an issue where a namespaced class beginning with "U" or "u"
would yield an invalid arginfo file due to the occurrence of a unicode
escape sequence, causing a compile error.

Co-authored-by: Guilliam Xavier <guilliamxavier@users.noreply.github.com>

Closes GH-9154.
2022-07-28 14:30:11 +02:00
Adam Saponara
8cf9c2f200
Fix GH-9090: Support assigning function pointers in FFI
Closes GH-9107.
2022-07-27 10:42:25 +02:00
Máté Kocsis
f4b5051c29
Declare ext/zend_test constants in stubs (#9135) 2022-07-25 20:55:58 +02:00
George Peter Banyard
4457dba1fb
Add support for stubs to declare intersection type class properties (#8751) 2022-07-22 13:04:49 +01:00
Ilija Tovilo
41a5b46e7d
Fix RC debug of stub attribute (#9082) 2022-07-21 15:06:04 +02:00
Jakub Zelenka
0a4a55fd44
Allow to not close stream on rscr dtor in php cli sapi 2022-07-18 10:58:50 +01:00