1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Commit Graph

1068 Commits

Author SHA1 Message Date
Peter Kokot
c89b363fc9 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/*/Makefile.frag: install programs built with libtool, with libtool
2026-02-23 17:20:59 +01:00
Michael Orlitzky
db6cca26dd sapi/*/Makefile.frag: install programs built with libtool, with libtool
When installing executables that were built using libtool, we are
supposed to use

  $ libtool --mode-install <install-command>

rather than the bare <install-command>. This is discussed ever so
briefly in the "Installing executables" section of the GNU libtool
documentation:

  https://www.gnu.org/software/libtool/manual/libtool.html

So far this has not caused a problem with GNU libtool on the platforms
that PHP supports, but there is an alternate libtool implementation
called slibtool that stores wrappers at the locations where PHP is
expecting the true executables to live. As a result, the wrappers (and
not the executables) are installed when slibtool is used to build PHP.

This is fixed by replacing,

  $(INSTALL)

with

  $(LIBTOOL) --mode=install $(INSTALL)

in the install-foo rules for the executables that are built with
libtool.

Closes GH-13674
2026-02-23 17:19:23 +01:00
Gina Peter Banyard
e1c8ed614e Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/phpdbg: use 'h' ZPP specifier instead of'H'
2025-11-13 01:32:14 +00:00
Gina Peter Banyard
a7fd6fc8d6 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  sapi/phpdbg: use 'h' ZPP specifier instead of'H'
2025-11-13 01:31:42 +00:00
Gina Peter Banyard
414e7db68a sapi/phpdbg: use 'h' ZPP specifier instead of'H'
The stubs say array so in debug mode we get a ZPP violation assertion and even by fixing the stubs the behaviour is not identical due to missing indirect handling.

This indicates using objects was never done, thus use the correct ZPP specifier
2025-11-12 16:01:43 +00:00
Tim Düsterhus
37bf0ec961 main: Deprecate deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string (#19606)
* main: Ignore `register_argc_argv` when `SG(request_info).argc` is available

* sapi: Remove hardcoded `register_argc_argv` for CLI SAPIs

This INI is ignored since the previous commit, which makes the hardcoded
setting obsolete.

* main: Deprecate deriving $_SERVER['argc'] and $_SERVER['argv'] from the query string

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_register_argc_argv_ini_directive

* main: Adjust deprecation message for `register_argc_argv`

* NEWS/UPGRADING
2025-09-09 10:34:35 +02:00
Ilija Tovilo
8a4cbde8c7 Use ull integer suffix for bitwise logic (GH-19673)
If (brake->type+1) exeeds 30, we have undefined behavior and won't actually
remove the relevant bit.

See GH-19633
2025-09-03 13:29:12 +02:00
Arnaud Le Blanc
73b98a3858 TAILCALL VM
Introduce the TAILCALL VM, a more efficient variant of the CALL VM:

 * Each opcode handler tailcalls the next opcode handler directly instead of
   returning to the interpreter loop. This eliminates call and interpreter loop
   overhead.
 * Opcode handlers use the preserve_none calling convention to eliminate
   register saving overhead.
 * preserve_none uses non-volatile registers for its first arguments, so
   execute_data and opline are usually kept in these registers and no code is
   required to forward them to the next handlers.

Generated machine code is similar to a direct-threaded VM with register pinning,
like the HYBRID VM.

JIT+TAILCALL VM also benefits from this compared to JIT+CALL VM:

 * JIT uses the registers of the execute_data and opline args as fixed regs,
   eliminating the need to move them in prologue.
 * Traces exit by tailcalling the next handler. No code is needed to forward
   execute_data and opline.
 * No register saving/restoring in epilogue/prologue.

The TAILCALL VM is used when the HYBRID VM is not supported, and the compiler
supports the musttail and preserve_none attributes: The HYBRID VM is used when
compiling with GCC, the TAILCALL VM when compiling with Clang>=19 on x86_64 or
aarch64, and the CALL VM otherwise.

This makes binaries built with Clang>=19 as fast as binaries built with GCC.
Before, these were considerably slower (by 2.8% to 44% depending on benchmark,
and by 5% to 77% before 76d7c616bb).

Closes GH-17849
Closes GH-18720
2025-08-22 18:05:52 +02:00
Alexandre Daubois
dfa1307a64 Various return types and values consolidation (#19418) 2025-08-12 11:28:41 +01:00
Tim Düsterhus
3d9d68e1ca zend_compile: Deprecate backticks as an alias for shell_exec() (#19443)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_backticks_as_an_alias_for_shell_exec
2025-08-12 12:02:13 +02:00
Gina Peter Banyard
d9000b3094 tree: replace some unnecessary uses of spprintf (#19354) 2025-08-05 17:25:47 +01:00
Alexandre Daubois
433c00b348 [skip ci] tree: Fix various typos (#19366) 2025-08-04 15:15:52 +01:00
Peter Kokot
3b45b9d74e Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix -Wuseless-escape warnings emitted by re2c (#19050)
2025-07-07 09:52:51 +02:00
Peter Kokot
ab6e73066b Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix -Wuseless-escape warnings emitted by re2c (#19050)
2025-07-07 09:51:50 +02:00
Peter Kokot
258fbd6bf9 Fix -Wuseless-escape warnings emitted by re2c (#19050)
re2c version 4 enabled some warnings by default. This fixes re2c code
for the `-Wuseless-escape` warnings.

There are two same issues reported.
Issue: GH-17523
Closes: GH-17204
2025-07-07 09:51:25 +02:00
Niels Dossche
7f3a2bc727 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix 'phpdbg --help' segfault on shutdown with USE_ZEND_ALLOC=0
2025-06-10 19:23:03 +02:00
Niels Dossche
6685414a77 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix 'phpdbg --help' segfault on shutdown with USE_ZEND_ALLOC=0
2025-06-10 19:22:56 +02:00
Niels Dossche
0cd3ebfc40 Fix 'phpdbg --help' segfault on shutdown with USE_ZEND_ALLOC=0
This hack not only breaks the handling of custom allocators, but also
breaks if zend_alloc is compiled with USE_CUSTOM_MM.
This hack is just no good, if you want leak information then use ASAN.

Closes GH-18813.
2025-06-10 19:22:24 +02:00
Niels Dossche
eb151e39b0 Properly handle reference return value from __toString()
It's possible to return a reference from __toString(), but this is not
handled and results in a (confusing) error telling that the return value
must be a string.
Properly handle this by unwrapping the reference.

Closes GH-18810.
2025-06-10 19:15:53 +02:00
DanielEScherzer
3f03f7ed3d [RFC] Add support for attributes on compile-time constants
https://wiki.php.net/rfc/attributes-on-constants
2025-04-29 11:53:09 -07:00
Arnaud Le Blanc
76d7c616bb Pass opline as argument to opcode handlers in CALL VM
This changes the signature of opcode handlers in the CALL VM so that the opline
is passed directly via arguments. This reduces the number of memory operations
on EX(opline), and makes the CALL VM considerably faster.

Additionally, this unifies the CALL and HYBRID VMs a bit, as EX(opline) is now
handled in the same way in both VMs.

This is a part of GH-17849.

Currently we have two VMs:

 * HYBRID: Used when compiling with GCC. execute_data and opline are global
   register variables
 * CALL: Used when compiling with something else. execute_data is passed as
   opcode handler arg, but opline is passed via execute_data->opline
   (EX(opline)).

The Call VM looks like this:

    while (1) {
        ret = execute_data->opline->handler(execute_data);
        if (UNEXPECTED(ret != 0)) {
            if (ret > 0) { // returned by ZEND_VM_ENTER() / ZEND_VM_LEAVE()
                execute_data = EG(current_execute_data);
            } else {       // returned by ZEND_VM_RETURN()
                return;
            }
        }
    }

    // example op handler
    int ZEND_INIT_FCALL_SPEC_CONST_HANDLER(zend_execute_data *execute_data) {
        // load opline
        const zend_op *opline = execute_data->opline;

        // instruction execution

        // dispatch
        // ZEND_VM_NEXT_OPCODE():
        execute_data->opline++;
        return 0; // ZEND_VM_CONTINUE()
    }

Opcode handlers return a positive value to signal that the loop must load a
new execute_data from EG(current_execute_data), typically when entering
or leaving a function.

Here I make the following changes:

 * Pass opline as opcode handler argument
 * Return next opline from opcode handlers
 * ZEND_VM_ENTER / ZEND_VM_LEAVE return opline|(1<<0) to signal that
   execute_data must be reloaded from EG(current_execute_data)

This gives us:

    while (1) {
        opline = opline->handler(execute_data, opline);
        if (UNEXPECTED((uintptr_t) opline & ZEND_VM_ENTER_BIT) {
            opline = opline & ~ZEND_VM_ENTER_BIT;
            if (opline != 0) { // ZEND_VM_ENTER() / ZEND_VM_LEAVE()
                execute_data = EG(current_execute_data);
            } else {           // ZEND_VM_RETURN()
                return;
            }
        }
    }

    // example op handler
    const zend_op * ZEND_INIT_FCALL_SPEC_CONST_HANDLER(zend_execute_data *execute_data, const zend_op *opline) {
        // opline already loaded

        // instruction execution

        // dispatch
        // ZEND_VM_NEXT_OPCODE():
        return ++opline;
    }

bench.php is 23% faster on Linux / x86_64, 18% faster on MacOS / M1.

Symfony Demo is 2.8% faster.

When using the HYBRID VM, JIT'ed code stores execute_data/opline in two fixed
callee-saved registers and rarely touches EX(opline), just like the VM.

Since the registers are callee-saved, the JIT'ed code doesn't have to
save them before calling other functions, and can assume they always
contain execute_data/opline. The code also avoids saving/restoring them in
prologue/epilogue, as execute_ex takes care of that (JIT'ed code is called
exclusively from there).

The CALL VM can now use a fixed register for execute_data/opline as well, but
we can't rely on execute_ex to save the registers for us as it may use these
registers itself. So we have to save/restore the two registers in JIT'ed code
prologue/epilogue.

Closes GH-17952
2025-04-15 18:51:54 +02:00
Christoph M. Becker
650086f3e6 Exclude unused functions from compilation units (GH-17686)
This avoids Clang complaining with `-Wunused-function`.

We also introduce the macro `PRELOAD_SUPPORT` for clarification.
2025-02-10 18:00:19 +01:00
Christoph M. Becker
4373c601ea Remove more unused local variables (GH-17688)
Since `pdo_odbc_ucs22utf8()` doesn't actually use the `stmt`, we drop
this parameter as well.
2025-02-03 20:06:29 +01:00
Christoph M. Becker
3955b01653 Avoid duplicate build rules
On Windows, the cli and phpdbg SAPIs have variants (cli-win32 and
phpdbgs, respectively) which are build by default.  However, the
variants share some files, what leads to duplicate build rules in the
generated Makefile.  NMake throws warning U4004[1], but proceeds
happily, ignoring the second build rule.  That means that different
flags for duplicate rules are ignored, hinting at a potential problem.

We solve this by introducing an additional (optional) argument to
`SAPI()` and `ADD_SOURCES()` which can be used to avoid such duplicate
build rules.  It's left to the SAPI maintainers to make sure that
appropriate rules are created.  We fix this for phpdbgs right away,
which currently couldn't be build without phpdbg due to the missing
define; we remove the unused `PHP_PHPDBG_EXPORTS` flag altogether.

[1] <https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/nmake-warning-u4004>

Closes GH-17545.
2025-02-01 11:21:09 +01:00
Niels Dossche
ef10339fe7 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in phpdbg calling registered function
  Partially fix GH-17387
2025-01-30 19:32:28 +01:00
Niels Dossche
29bafa6323 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in phpdbg calling registered function
  Partially fix GH-17387
2025-01-30 19:31:38 +01:00
ndossche
62bbfdebaa Fix memory leak in phpdbg calling registered function
Closes GH-17635.
2025-01-30 19:28:26 +01:00
ndossche
5447473785 Partially fix GH-17387
The length of the string should be set to the truncated length (that was
used to duplicate the input anyway).
2025-01-30 19:28:23 +01:00
Christoph M. Becker
26bf239e6d Resolve -Wincompatible-pointer-types warnings (GH-17456)
The phpdbg issue is a real issue, although it's unlikely that harm can
be done due to stack alignment and little-endianess.  The others seem
to be more cosmetic.
2025-01-13 10:54:13 +01:00
Niels Dossche
2860c3d641 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix crashes in function registration + test
2025-01-06 21:31:03 +01:00
Niels Dossche
1235c74828 Fix crashes in function registration + test
Internal function won't need their refcount increased as they outlive
the debugger session, and userland functions won't be unloaded either.
So no refcount management is necessary for registered functions.
2025-01-06 21:30:34 +01:00
Gina Peter Banyard
e2e7b46542 sapi/phpdbg: Grab the function pointer directly
Allocating a string zval to let zend_call_function() do the same thing is slightly pointless
2025-01-06 20:17:25 +00:00
Niels Dossche
a58c6d56bb Make docs consistent with help text 2025-01-06 20:17:25 +00:00
Niels Dossche
8cb15f6203 Fix crashes in function registration + test
Internal function won't need their refcount increased as they outlive
the debugger session, and userland functions won't be unloaded either.
So no refcount management is necessary for registered functions.
2025-01-06 20:17:25 +00:00
Tim Düsterhus
3fea6468fe phpdbg: Call enums “Enum” and traits “Trait” in info classes (#17191)
* phpdbg: Call enums “Enum” in `info classes`

* phpdbg: Call traits “Trait” in `info classes`
2024-12-17 19:32:47 +01:00
Niels Dossche
c2a6a7da7b Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
2024-11-26 22:27:40 +01:00
Niels Dossche
5ff67f8720 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
2024-11-26 22:27:35 +01:00
Niels Dossche
3c3ec0e61a Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
2024-11-26 22:27:06 +01:00
Niels Dossche
97b03186c4 Fix GH-15208: Segfault with breakpoint map and phpdbg_clear()
It crashes because it's gonna try accessing the breakpoint which was cleared
by user code in `phpdbg_clear();`. Not all breakpoint data was properly
cleaned.

Closes GH-16953.
2024-11-26 22:26:37 +01:00
Gina Peter Banyard
6ddab74d55 sapi: Fix some variable shadowing (#16485)
sapi_module, mime_type_map, zend_extensions, php_cgi_globals, and phpdbg_globals are true globals which are being shadowed
2024-10-17 22:46:23 +01:00
Christoph M. Becker
4d3240261d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16174: Empty string is an invalid expression for phpdbg-ev
2024-10-10 01:47:52 +02:00
Christoph M. Becker
980d41cb3a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16174: Empty string is an invalid expression for phpdbg-ev
2024-10-10 01:47:23 +02:00
Christoph M. Becker
5c6fc09e45 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16174: Empty string is an invalid expression for phpdbg-ev
2024-10-10 01:46:30 +02:00
Christoph M. Becker
6bcba24eb0 Fix GH-16174: Empty string is an invalid expression for phpdbg-ev
Strings may be empty, so we must not assume they are not.

Closes GH-16177.
2024-10-10 01:45:37 +02:00
Gina Peter Banyard
2d217f08b8 sapi/phpdbg: Use HASH_FOREACH macro (#16211) 2024-10-07 00:17:30 +01:00
Arnaud Le Blanc
2d8a93cbb6 Merge branch 'PHP-8.4'
* PHP-8.4:
  [ci skip] NEWS for GH-16055
  Support stack limit in phpdbg SAPI
2024-10-03 15:25:57 +02:00
Arnaud Le Blanc
443aa29dbe Support stack limit in phpdbg SAPI
Fixes GH-16041
Closes GH-16055
2024-10-03 15:22:51 +02:00
Christoph M. Becker
2f09c0ed0f Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-16181: phpdbg: exit in exception handler reports fatal error
2024-10-03 11:39:34 +02:00
Christoph M. Becker
3c1af3febb Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16181: phpdbg: exit in exception handler reports fatal error
2024-10-03 11:39:03 +02:00
Christoph M. Becker
95c97c81b7 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16181: phpdbg: exit in exception handler reports fatal error
2024-10-03 11:37:15 +02:00