Commit Graph

416 Commits

Author SHA1 Message Date
DanielEScherzer
aeb2d5cfa6
ext/[ef]*: fix a bunch of typos (GH-16621) 2024-10-28 11:28:32 +01:00
Christoph M. Becker
ae717797e5
Fix Windows x86 build for ext/ffi
PR #16351 introduced `EnumProcessModules()` calls, but this function is
undefined; thus, the compiler mangles the name according to the default
calling convention.  This lets linking succeed for x64, but fail for
x86.

To properly fix this, we include <Psapi.h> where the function is
declared.
2024-10-20 11:57:44 +02:00
Christoph M. Becker
db991bc0f1
FFI: support symbol lookup without specifying lib on Windows
This works similar to `dlsym(RTLD_DEFAULT, …)` with the caveat that
symbols on Windows may not be unique, and are usually qualified by the
module they are exported from.  That means that wrong symbols may be
fetched, potentially causing serious issues; therefore this usage is
not recommended for production purposes, but is a nice simplification
for quick experiments and the ext/ffi test suite.

Closes GH-16351.
2024-10-19 15:36:49 +02:00
Niels Dossche
8f1543a76e
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16397: Segmentation fault when comparing FFI object (#16401)
2024-10-14 19:24:23 +02:00
Niels Dossche
7a7ab73d3b
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16397: Segmentation fault when comparing FFI object (#16401)
2024-10-14 19:24:17 +02:00
Niels Dossche
c924af0d6b
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16397: Segmentation fault when comparing FFI object (#16401)
2024-10-14 19:24:01 +02:00
Niels Dossche
ec8a24f746
Fix GH-16397: Segmentation fault when comparing FFI object (#16401)
`compare` is a required handler [1], but this handler was set to NULL.
Throw an exception when trying to compare FFI objects.

[1] 35c8a010c6/Zend/zend_object_handlers.h (L231C1-L231C64)

Closes GH-16401.
2024-10-14 19:23:04 +02:00
Christoph M. Becker
9345582471
XLEAK bug78270_2.phpt (GH-16352)
This test leaks memory as some other ext/ffi tests, so we treat it in
the same way.

We also fix a typo in another test.
2024-10-11 10:27:37 +02:00
Dmitry Stogov
a37a3d3d81
Fix FFI prototypes (these functions can't return NULL) (#16075) 2024-09-26 20:19:46 +03:00
Peter Kokot
888eb370cf
Fix -Wundef/C4668 warnings (#15853)
- ZTS is either undefined or defined (to 1)
- PHP_WIN32 is either undefined or defined (to 1)
- HAVE_LIBEDIT is either undefined or defined (to 1)
2024-09-14 11:28:32 +02:00
Bob Weinand
25d761623c
Make internal run_time_cache a persistent allocation (#15040)
We also add zend_map_ptr_static, so that we do not incur the overhead of constantly recreating the internal run_time_cache pointers on each request.
This mechanism might be extended for mutable_data of internal classes too.
2024-09-07 01:45:26 +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
Arnaud Le Blanc
58aa6fc830
Lazy objects
RFC: https://wiki.php.net/rfc/lazy-objects

Closes GH-15019
2024-08-30 17:30:03 +02:00
Máté Kocsis
8d12f666ae
Fix registration of internal readonly child classes (#15459)
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.
2024-08-24 12:36:54 +02:00
Christoph M. Becker
450740cbb6
[skip ci] Fix typos in XFAIL reasons 2024-08-22 11:48:46 +02:00
Peter Kokot
d6a75e19d1
Sync preprocessor macros help texts (#15218)
This partially syncs help texts a bit further for:
- ext/ffi
- ext/ldap
- ext/opcache
- ext/pcre
- ext/pdo_mysql
- ext/readline
- ext/standard
2024-08-04 12:52:16 +02:00
Peter Kokot
f66feaec0f
Sync HAVE_<extension> help texts (#15167)
This syncs all help texts of extension preprocessor macros to the same
style "Define to 1 if the PHP extension '<ext>' is available.".
[skip ci]
2024-08-02 01:41:47 +02:00
Peter Kokot
eed66e6183
Autotools: Fix ffi checks (#15197)
When libffi is installed on non-default places, also the calling
convention checks need adjusted compilation flags to be able to find the
ffi.h header file.
2024-08-02 00:32:36 +02:00
Peter Kokot
1ceadaed52
Autotools: Normalize and quote all PHP_NEW_EXTENSION arguments (#15144)
This adds Autoconf quote characters to all PHP_NEW_EXTENSION arguments
and syncs the CS across the php-src Autotools build system.
2024-07-29 00:14:59 +02:00
Peter Kokot
ef8e792962
Autotools: Quote M4 macro arguments
- AC_CHECK_TYPES
- AC_REPLACE_FUNCS
- PHP_HELP_SEPARATOR needs here double quotes as content contains '['
  and ']' characters
2024-07-27 11:22:28 +02:00
Niels Dossche
77f870e98e
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14286 (ffi enum type (when enum has no name) make memory leak)
2024-07-22 17:45:28 +02:00
Niels Dossche
b2963e96ee
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14286 (ffi enum type (when enum has no name) make memory leak)
2024-07-22 17:45:20 +02:00
Niels Dossche
c0de7214aa
Fix GH-14286 (ffi enum type (when enum has no name) make memory leak)
For top-level anonymous type definition we never store the declaration anywhere
else nor the type anywhere else.
The declaration keeps owning the type and it goes out of scope.
For anonymous fields this gets handled by the add_anonymous_field code that
removes the type from the declaration.
This patch does something similar in the parsing code when it is
detected we're dealing with an anonymous enum in a top-level declaration.

Closes GH-14839.
2024-07-22 17:44:47 +02:00
Dmitry Stogov
e4d86998f6
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix Windows build
2024-07-22 16:41:43 +03:00
Dmitry Stogov
0338e8d4ec
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix Windows build
2024-07-22 16:41:35 +03:00
Dmitry Stogov
d6efff7254
Fix Windows build 2024-07-22 16:41:16 +03:00
Dmitry Stogov
037da5941c
Merge branch 'PHP-8.3'
* PHP-8.3:
  Regenerate FFI parser using HEAD version of LLK
2024-07-22 16:02:12 +03:00
Dmitry Stogov
eb7bb586e2
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Regenerate FFI parser using HEAD version of LLK
2024-07-22 16:01:59 +03:00
Dmitry Stogov
13e9b40517
Regenerate FFI parser using HEAD version of LLK 2024-07-22 16:01:26 +03:00
Peter Kokot
68ae477796
Autotools: Quote M4 arguments (#15033)
- PHP_ADD_INCLUDE
- PHP_EVAL_INCLINE
- PHP_EVAL_LIBLINE
2024-07-20 07:21:44 +02:00
Peter Kokot
bee84c0468
Autotools: Quote PHP_SUBST arguments in extensions (#14748) 2024-07-02 06:56:18 +02:00
Arnaud Le Blanc
f7df238971
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS for GH-14626
  [ci skip] NEWS for GH-14626
  Fix is_zend_ptr() for huge blocks (#14626)
2024-06-25 15:18:58 +02:00
Arnaud Le Blanc
bc57c77fa2
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS for GH-14626
  Fix is_zend_ptr() for huge blocks (#14626)
2024-06-25 15:15:46 +02:00
Arnaud Le Blanc
1ff277dee2
Fix is_zend_ptr() for huge blocks (#14626)
is_zend_ptr() expected zend_mm_heap.huge_list to be circular, but it's in fact NULL-terminated. It could crash when at least one huge block exists and the ptr did not belong to any block.
2024-06-25 15:14:00 +02:00
Peter Kokot
5e242fea66
Use AC_DEFINE_UNQUOTED where variables are present (#14377)
According to Autoconf docs and upstream code, AC_DEFINE_UNQUOTED must be
used where variables are present in the arguments.

Follow up of GH-13552
2024-05-30 21:50:46 +02:00
Gina Peter Banyard
554541c4db
ext/ffi: Fix [-Wenum-int-mismatch] compiler warning 2024-05-21 12:17:25 +01:00
Máté Kocsis
f093015a6c
Fix class constant and property ID generation for the manual (#14249)
Related to https://github.com/php/doc-en/pull/3367
2024-05-17 20:30:16 +02:00
Niels Dossche
889f308e01
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14215: Cannot use FFI::load on CRLF header file with apache2handler
2024-05-14 19:56:05 +02:00
Niels Dossche
0e98a05a3d
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14215: Cannot use FFI::load on CRLF header file with apache2handler
2024-05-14 19:52:19 +02:00
Niels Dossche
ebd1a36670
Fix GH-14215: Cannot use FFI::load on CRLF header file with apache2handler
Some modules may reset _fmode, which causes mangling of line endings.
Always be explicit like we do in other places where the native open call
is used.

Closes GH-14218.
2024-05-14 19:49:22 +02:00
Niels Dossche
8aec95e23f
Fix build on Clang 18 (#14136)
Clang 18 only allows counted_by to work on real flexible array members,
not ones with a zero size. Otherwise you get errors like:
```
ext/opcache/jit/zend_jit_ir.c:149:12: error: 'counted_by' only applies to C99 flexible array members
```
2024-05-04 19:17:42 +02:00
Tim Düsterhus
08b2ab22f4
Include the source location in Closure names (#13550)
* Include the source location in Closure names

This change makes stack traces involving Closures, especially multiple
different Closures, much more useful, because it's more easily visible *which*
closure was called for a given stack frame.

The implementation is similar to that of anonymous classes which already
include the file name and line number within their generated classname.

* Update scripts/dev/bless_tests.php for closure naming

* Adjust existing tests for closure naming

* Adjust tests for closure naming that were not caught locally

* Drop the namespace from closure names

This is redundant with the included filename.

* Include filename and line number as separate keys in Closure debug info

* Fix test

* Fix test

* Include the surrounding class and function name in closure names

* Fix test

* Relax test expecations

* Fix tests after merge

* NEWS / UPGRADING
2024-04-12 18:21:13 +02:00
Bob Weinand
18496cc3d4 Merge branch 'PHP-8.3' 2024-04-02 18:13:10 +02:00
Bob Weinand
dbaeb62ab1 Merge branch 'PHP-8.2' of github.com:php/php-src into PHP-8.3 2024-04-02 18:11:55 +02:00
Bob Weinand
e7462bff19
Run one testsuite with observers enabled in CI (#13869)
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2024-04-02 18:11:02 +02:00
Niels Dossche
b9a2533cb3
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix gcc-14 Wcalloc-transposed-args warnings
2024-04-01 20:34:44 +02:00
Niels Dossche
e34c86ce1a
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix gcc-14 Wcalloc-transposed-args warnings
2024-04-01 20:34:37 +02:00
Cristian Rodríguez
18d70db091
Fix gcc-14 Wcalloc-transposed-args warnings
gcc-14 and later warns of inverted arguments in calloc or
calloc-like __alloc_size__ annotated functions.

Closes GH-13818.
2024-04-01 20:34:14 +02:00
Peter Kokot
b5e2f3a4b6
Check FFI_* ABI with Autoconf AC_CHECK_DECL (#13552)
The FFI_* calling conventions are enum constants and AC_CHECK_DECL(S)
can be used to check for their existence in the ffi.h header. This
simplifes the checks and adds a simple AC_CHECK_DECL macro wrapper which
defines the HAVE_FFI_* belonging symbols.
2024-03-01 19:31:55 +01:00
Máté Kocsis
f2e199e878
Implement "support doc comments for internal classes and functions" (#13266)
Fixes #13130
2024-02-25 08:41:31 +01:00