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

141181 Commits

Author SHA1 Message Date
Niels Dossche
eeaa60f6fa Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix reference support for intltz_get_offset()
2025-04-20 14:24:02 +02:00
Niels Dossche
affffe1122 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix reference support for intltz_get_offset()
2025-04-20 14:23:56 +02:00
Niels Dossche
bf4b470098 Fix reference support for intltz_get_offset()
It should use the helper macros such that types are properly respected.

Closes GH-18364.
2025-04-20 14:23:31 +02:00
Niels Dossche
e9b01f202b Use pre-allocated array sizes and packed where possible in intl 2025-04-20 12:18:15 +02:00
Niels Dossche
68b904884b Factor out duplicated code 2025-04-20 12:17:50 +02:00
Niels Dossche
dc9039086c Avoid pointless refcounting in php_intl_idn_to_46() 2025-04-20 12:17:50 +02:00
Niels Dossche
f39c07a3bb DOM/XPath: Use RETURN_NEW_STR
These strings are newly allocated and can't be interned, so we can use
RETURN_NEW_STR.
2025-04-19 18:00:00 +02:00
Niels Dossche
35e96f621b DOM/XPath: Use ZSTR_LEN abstraction instead of direct member access 2025-04-19 18:00:00 +02:00
Niels Dossche
91a310e603 Get rid of separate DOM HashPosition member (#18354)
Besides the fact that this is only used for DOM_NODESET and thus makes
no sense of being on the iterator itself, it's also redundant now that
we have the index member.
2025-04-19 17:59:48 +02:00
David CARLIER
2e7df9e423 ext/gd: imagefilter* using overflow checks. (#18283)
Accept up to UINT_MAX * sizeof(int) colors.
2025-04-19 16:27:14 +01:00
Kamil Tekiela
25f4f7982c Drop unused variables (#18023) 2025-04-19 13:26:09 +01:00
David Carlier
fcd0f72cdd GH-18345: adding Locale::isRightToLeft.
Checks is the locale is written left to right.
It makes sure all the needed likely subtags are included (maximization)
then determines the direction by known matches.

close GH-18351
2025-04-19 10:23:03 +01:00
David CARLIER
ba83d5daeb sapi/litespeed and ext/standard: Fix few build warnings. (#18265) 2025-04-19 10:18:53 +01:00
Saki Takamachi
23687672f3 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed GH-17383 - pdo_firebird: PDOException has wrong code and message since PHP 8.4 (#18072)
2025-04-19 14:11:35 +09:00
Saki Takamachi
685baf77df Fixed GH-17383 - pdo_firebird: PDOException has wrong code and message since PHP 8.4 (#18072)
Closes #18072
Fixes #17383
2025-04-19 14:11:20 +09:00
Niels Dossche
8376904aeb Implement GH-17321: Add setAuthorizer to Pdo\Sqlite (#17905) 2025-04-18 00:34:46 +02:00
Ilija Tovilo
87499e44f2 Fix use of magic const within const expr cast (GH-18338)
Fixes OSS-Fuzz #410939023
2025-04-16 20:00:40 +02:00
Niels Dossche
66d5cf8d2d Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak on error return of collation callback in pdo_sqlite
2025-04-16 13:52:34 +02:00
Niels Dossche
ce7304f909 Fix memory leak on error return of collation callback in pdo_sqlite
We should destroy it when it's not IS_LONG, not when it's IS_LONG.

Closes GH-18332.
2025-04-16 13:52:23 +02:00
Niels Dossche
2d3ac4e2ed Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix NULL deref on high modification key
2025-04-16 11:41:33 +02:00
Niels Dossche
bfa2cfc9ed Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix NULL deref on high modification key
2025-04-16 11:38:38 +02:00
Niels Dossche
c905d59106 Fix NULL deref on high modification key
We should re-index in the loop.

Closes GH-18331.
2025-04-16 11:37:49 +02:00
Niels Dossche
b50f7c22c3 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak when handling a too long path in ZipArchive::addGlob()
  Fix uouv when handling empty options in ZipArchive::addGlob()
2025-04-16 10:46:23 +02:00
Niels Dossche
ecd2872cf4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak when handling a too long path in ZipArchive::addGlob()
  Fix uouv when handling empty options in ZipArchive::addGlob()
2025-04-16 10:46:17 +02:00
Niels Dossche
91c6c727d5 Fix memory leak when handling a too long path in ZipArchive::addGlob()
Closes GH-18330.
2025-04-16 10:45:35 +02:00
Niels Dossche
0a6326c6ac Fix uouv when handling empty options in ZipArchive::addGlob()
Reported by OpenAI AARDVARK.

php_zip_parse_option is only called when options are passed to the function.
Prior to this patch, php_zip_parse_option was responsible for zeroing the
opts variable. So in the case when php_zip_parse_option is not called,
opts remains uninitialized yet it is being used anyway.
By just always zeroing opts at declaration time, we avoid this issue
and we are unlikely to reintroduce this in the future.

Closes GH-18329.
2025-04-16 10:44:59 +02:00
Niels Dossche
ea387fcfb7 Avoid useless initializations of fci/fcc in array functions (#18273)
These cause cache misses due to global access, in phpstan
(notably the array_map).
Initializing these isn't necessary because ZPP initializes it for us.
Only for optional arguments do we need to be careful; for `array_filter`
we still reset the `fci` but not `fci_cache` because `fci` is not
necessarily set by ZPP but is conditionally used to access `fci_cache`.
2025-04-15 23:08:12 +02:00
Máté Kocsis
93a3256da8 Fix GH-18108 gen_stub: Using $this when not in object context 2025-04-15 20:56:11 +02: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
Arnaud Le Blanc
49891d89fc Merge branch 'PHP-8.4'
* PHP-8.4:
  Save opline in zend_jit_hot_func()
2025-04-15 14:11:53 +02:00
Florian Engelhardt
061b46e09d Save opline in zend_jit_hot_func()
Closes GH-18289
2025-04-15 14:11:32 +02:00
Arnaud Le Blanc
b24addddb4 run-tests.php: Save STDIN section into a file (#18305)
When a test has an --STDIN-- or --PHPDBG-- section, save the section's content into a file, like we do for the other sections.

This makes it bit easier to reproduce these tests outside of run-tests.php.

This doesn't update the .sh file to pass the file as stdin to the program, yet. 

When using gdb, we can pass the file as stdin like this:

    gdb --args php
    (gdb) r test.php < test.stdin
2025-04-15 14:02:08 +02:00
Ilija Tovilo
16c4c066f4 Make empty_fcall_info and empty_fcall_info_cache macros
See https://github.com/php/php-src/pull/18273, a constant may cause
unnecessary cache misses.

Closes GH-18326
2025-04-15 12:51:10 +02:00
Saki Takamachi
3b87093bff Merge branch 'PHP-8.4'
* PHP-8.4:
  Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted" with setAttribute() (#18280) Closes #18280 Fixes #18276
2025-04-15 09:07:06 +09:00
Saki Takamachi
0f5372dbaa followup in master for #18280 (#18302)
Closes #18302
2025-04-15 09:06:38 +09:00
Saki Takamachi
bd9f03a336 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted" with setAttribute() (#18280) Closes #18280 Fixes #18276
2025-04-15 09:04:39 +09:00
Saki Takamachi
9d4f8b5379 Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted" with setAttribute() (#18280)
Closes #18280
Fixes #18276
2025-04-15 09:01:40 +09:00
hanshenrik
0a10f6db26 ext/pdo_sqlite - throw on null bytes / resolve GH-13952 (#18320)
fix a corruption issue where PDO::quote for SQLite would silently truncate
strings with null bytes in them, by throwing.

Fixes #13952
Closes #18320
2025-04-15 08:52:31 +09:00
Máté Kocsis
93ad8e8db2 Merge branch 'PHP-8.4'
* PHP-8.4:
  Mark ob_start callback parameter nullable
2025-04-14 22:36:51 +02:00
Máté Kocsis
691e009f97 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Mark ob_start callback parameter nullable
2025-04-14 22:36:14 +02:00
haszi
701f3a1af6 Mark ob_start callback parameter nullable 2025-04-14 22:35:06 +02:00
Tim Düsterhus
9ac8820fc9 zend_compile: Allow (void) in for’s initializer and loop expression (#18303)
* zend_compile: Allow `(void)` in for’s initializer and loop expression

The initializer and loop expression of a `for()` loop only accept expressions,
but they act like statements in spirit - their results are completely ignored.
Allow `(void)` there to allow suppressing `#[\NoDiscard]`, since there is no
semantic ambiguity of what `(void)` returns anyways.

Fixes php/php-src#18301

* zend_language_parser: Simplify `for()` grammar
2025-04-14 15:36:51 +02:00
Niels Dossche
89e5f6ca53 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18322: SplObjectStorage debug handler mismanages memory
2025-04-14 14:11:40 +02:00
Niels Dossche
fc63a98f17 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18322: SplObjectStorage debug handler mismanages memory
2025-04-14 14:11:35 +02:00
Niels Dossche
67503870ca Fix GH-18322: SplObjectStorage debug handler mismanages memory
This hack was once necessary before there was a proper get_gc handler,
but now it breaks the engine constraints.

Closes GH-18323.
2025-04-14 14:11:09 +02:00
Niels Dossche
a142f10aa1 Don't evaluate GMP comparison multiple times (#18321)
ZEND_THREEWAY_COMPARE evaluates its operands multiple times.
2025-04-14 11:19:14 +02:00
Gina Peter Banyard
4eb8839037 ext/iconv: Use RETURN_BOOL() instead of if/else 2025-04-14 10:15:55 +01:00
Gina Peter Banyard
e1686aabf7 ext/iconv: Hardcode 0 for PHP_ICONV_ERR_SUCCESS value
Instead of relying on the zend_result SUCCESS value which doesn't have much to do with it here.
2025-04-14 10:15:55 +01:00
Gina Peter Banyard
2d3db4b594 ext/iconv: Use bool type instead of int type 2025-04-14 10:15:55 +01:00
Gina Peter Banyard
bba44fc3fe ext/iconv: Add const specifier 2025-04-14 10:15:55 +01:00