Commit Graph

135338 Commits

Author SHA1 Message Date
Ilija Tovilo
bc59e79d21
Merge branch 'PHP-8.3'
* PHP-8.3:
  Restore error handler after running it
2024-03-20 10:53:35 +01:00
Ilija Tovilo
3301d9602a
Restore error handler after running it
Symfony relies on finding the exception handler in the handler stack. There's
currently no clean API to find it, so they pop all the handlers, and push them
again once the stack is empty. This PR attempts to minimize the BC break by
pushing the current handler onto the stack and clearing the current handler, and
restoring it once it has finished. This is essentially equivalent to
set_exception_handler(null) and restore_exception_handler().

restore_exception_handler() however is only called if the exception handler is
still unset. If the handler has pushed a new handler in the meantime, we assume
it knows what it's doing.

Fixes GH-13446
Closes GH-13686
2024-03-20 10:53:20 +01:00
Tim Düsterhus
6fb20cd9de
random: Simplify implementation of php_random_generate_fallback_seed() (#13761)
As all the input bits and pieces are mixed with SHA-1, cross-architecture
compatibility is not required and we can just mix in whatever they may look
like in memory, instead of going through the `write_*()` helpers that were
created for a previous in-development version that first filled a buffer that
was then hashed (allowing for easy inspection of the input data, but making it
harder to safely add values without checking for buffer overflows all the
time).

This change should also fix a build error on macOS ZTS: The thread ID is an
opaque type and not guaranteed to be arithmetic as per IEEE Std 1003.1-2017.
And indeed macOS defines it as a pointer to a structure, failing due to the
implicit pointer to integer conversion.
2024-03-20 09:41:01 +01:00
David Carlier
2e7c6e1eb2 freebsd CI reeanable werror 2024-03-19 22:39:32 +00:00
David Carlier
623a980af3 Merge branch 'PHP-8.3' 2024-03-19 22:38:43 +00:00
David Carlier
f2f656c97e CI: update freebsd 13 image.
13.2 is going to be EOL.

close GH-13622
2024-03-19 22:36:33 +00:00
David Carlier
f2ec6e4806 Merge branch 'PHP-8.2' into PHP-8.3 2024-03-19 22:35:18 +00:00
David Carlier
db063cb771 CI: update freebsd 13 image.
13.2 is going to be EOL.

close GH-13622
2024-03-19 22:34:56 +00:00
Tim Düsterhus
807524d61c
random: Use CSPRNG for CombinedLCG seeding (#13748)
Now that the CombinedLCG is no longer used within GENERATE_SEED(), we can
safely use the CSPRNG with a php_random_generate_fallback_seed() fallback to
seed the CombinedLCG.
2024-03-19 20:13:44 +01:00
Ilija Tovilo
5b7d45822a
Fix missing llvm deps inside docker 2024-03-19 17:34:18 +01:00
Ilija Tovilo
25a8f155f2
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix ASan build
2024-03-19 17:17:21 +01:00
Ilija Tovilo
697d1a1c63
Fix ASan build
See https://github.com/actions/runner-images/issues/9491#issuecomment-1989718917

The mentioned workaround doesn't work for us because we run ASan inside Docker.
Instead, we switch to ubuntu-20.04 as the host. The docker setup itself remains
the same.

Closes GH-13757
2024-03-19 17:15:36 +01:00
Arnaud Le Blanc
df7252624f [ci skip] NEWS 2024-03-19 13:06:29 +01:00
Arnaud Le Blanc
1bae61a4d2
Compress interned string table offsets and increase maximum supported buffer size (#13676)
Compress interned string table offsets and increase maximum supported buffer size

The interned string buffer is organized as a header + a hash table + a
zend_string arena. Hash slots point to the arena, but are represented as 32bit
offsets from the buffer, which limits the maximum buffer size to about 4GiB.
However zend_strings are 8-byte aligned in the buffer, so we can compress the
3 lower bits. This allows to increase the maximum supported interned string
buffer size from 4095 MiB to 32767 MiB.
2024-03-19 13:01:30 +01:00
Máté Kocsis
5bb03158b6
Add the last few remaining constants to stubs (#13751)
Basically all constants are now declared via stubs. The rest of the constants are either deprecated (`SID` or `MHASH_*`) or out of interest (`__COMPILER_HALT_OFFSET__` and `PHP_CLI_PROCESS_TITLE`).
2024-03-19 08:20:33 +01:00
David CARLIER
51dafc6054
Fix GH-13745: fix header inclusion in pdo_pgsql.c (#13749)
pdo/php_pdo_int.h is not part of the PDO's headers to install.
2024-03-18 23:07:41 +00:00
Máté Kocsis
5992a29724
Improve BC support of arginfo files fenerated by gen_stub.php (#13705)
- Declared compatibility expectations of stub files are now enforced by a ZEND_STATIC_ASSERT call at the top of arginfo files
- Property registration for PHP 7 is fixed: function zend_declare_property_ex() is used again instead of zend_declare_typed_property(). This has been a regression since I added support for exposing doc comments.
- As a defensive measure, deep cloning is performed before newer features (type declarations, attributes etc.) are discarded before generating legacy arginfo files. Until now, some of the objects were forgotten to be taken care of. These omissions may have resulted in some weird bugs in theory (but probably they didn't have much impact in practice).
- PHP version related conditions inside *non-legacy arginfo files* used to possibly check for the 70000 version iD until now if compatibility with PHP 7.0 was declared in a stub. This was not 100% correct, since non-legacy arginfo files are only for PHP 8.0+. Now, I made sure that at least PHP version ID 80000 is used in the preprocessor conditions. The solution was a bit tricky though...
2024-03-18 22:06:17 +01:00
Bob Weinand
4e934d789e Merge branch 'PHP-8.3' 2024-03-18 20:26:24 +01:00
Bob Weinand
50fe64c345 Merge branch 'PHP-8.2' of https://github.com/php/php-src into PHP-8.3 2024-03-18 20:26:00 +01:00
Bob Weinand
059bf33e60
Properly forward the signal to the original handler if TSRM is shutdown. (#10219)
This ensures proper handling of SIGQUIT in ZTS fpm builds outside of active requests.
2024-03-18 20:24:23 +01:00
Dmitry Stogov
968a807d97 Update IR
IR commit: 84df6f8d409c7d06daa68d96a25d0aed81dcbf4a
2024-03-18 21:47:06 +03:00
Bob Weinand
9bed0b5f2f Merge branch 'PHP-8.3' 2024-03-18 19:06:12 +01:00
Bob Weinand
6d6cd29909 Merge branch 'PHP-8.2' of https://github.com/php/php-src into PHP-8.3 2024-03-18 19:04:12 +01:00
Bob Weinand
10d912d6e3
Fix GH-13712: Segmentation fault for enabled observers when calling trait method of internal trait when opcache is loaded (#13735)
Inherited methods regardless of source must share the original runtime cache. Traits were missed.
This adds ZEND_ACC_TRAIT_CLONE to internal functions as well to allow easy distinction of these.
2024-03-18 19:02:42 +01:00
Niels Dossche
f47b7f1c70
Cleanup name handling in magic methods (#13733)
The copy was introduced in bc59289b7, and later changed in 57527455eb,
to prevent indirect modifications of magic method arguments.
This is no longer necessary because we no longer deal with zvals, but
with string directly that the VM has retrieved either as a constant, or
via zval_try_get_tmp_string().
2024-03-18 17:48:12 +01:00
Marc Bennewitz
805326fe18
An uninitialized DateTime is UNEXPECTED (#13492) 2024-03-18 16:38:30 +00:00
Bob Weinand
d539c4b8f6 Merge branch 'PHP-8.3' 2024-03-18 17:22:48 +01:00
Bob Weinand
35aef8ee87 Merge branch 'PHP-8.2' of https://github.com/php/php-src into PHP-8.3 2024-03-18 17:22:23 +01:00
Bob Weinand
6fb8b9d721 Fix possible segfault with 0x0 shared opcache base
Moving the minimum base of the shared opcache memory to the second huge page to avoid a possible 0x0 base, which may cause all sorts of segfaults.
This is not a problem on most systems which have a mmap_min_addr which is non-zero, but e.g. WSL1 doesn't have a minimum mapping address.
2024-03-18 17:18:33 +01:00
Tim Düsterhus
81744d6cf7
random: Improve the output quality of RANDOM_SEED() (#13730)
* random: Improve the output quality of RANDOM_SEED()

Previously 4 consecutive calls to `RANDOM_SEED()` each for 4 different CLI
requests resulted in:

    $ sapi/cli/php test.php
    2c13e9fde9caa
    2c13e9fd1d6b0
    2c13e9fd4de34
    2c13e9fd1610e
    $ sapi/cli/php test.php
    2c1436764fe07
    2c14367621770
    2c143676c0bf6
    2c143676e02f5
    $ sapi/cli/php test.php
    2c144995a0626
    2c14499590fe2
    2c144995c65db
    2c14499536833
    $ sapi/cli/php test.php
    2c145cb30860b
    2c145cb3ec027
    2c145cb33b4ca
    2c145cb38ff63

Now they result in:

    $ sapi/cli/php test.php
    6796973ace1b5f3d
    1913daf5c158cb4b
    255dbf24237bc8c9
    7c3ba22e60f35196
    $ sapi/cli/php test.php
    afb7cc9ba9819cd2
    3e01a71b91ad020c
    6b718364d3ef108
    bdcd17beeb4b31d2
    $ sapi/cli/php test.php
    53d36eb9b83f8788
    4381c85e816187aa
    2e9b32ee9898e71e
    31d15c946842bddb
    $ sapi/cli/php test.php
    2037a3cba88114b4
    ba0b0d93a9bb43aa
    e13d82d2421269e2
    191de474f3292240

* tree-wide: Replace GENERATE_SEED() by php_random_generate_fallback_seed()

* random: Fix NTS build

* random: Fix Windows build
2024-03-18 16:08:23 +01:00
Peter Kokot
4f7a3d9053
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12019: ext/gd/config.m4: don't forget GDLIB_CFLAGS in feature tests
2024-03-18 11:59:34 +01:00
Peter Kokot
f66696548b
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12019: ext/gd/config.m4: don't forget GDLIB_CFLAGS in feature tests
2024-03-18 11:58:56 +01:00
Michael Orlitzky
00799320ec
Fix GH-12019: ext/gd/config.m4: don't forget GDLIB_CFLAGS in feature tests
In commit 85e5635a, a feature test for the various libgd image formats
was added. That test however erroneously omits the GDLIB_CFLAGS (from
pkg-config) during compilation. This can lead to build failures and
therefore false negatives from the test.

Here, we add $GDLIB_CFLAGS to $CFLAGS for the duration of the test.

Closes GH-12019
2024-03-18 11:57:20 +01:00
David Carlier
952cc2a675 Merge branch 'PHP-8.3' 2024-03-18 06:59:29 +00:00
David Carlier
839153069f Merge branch 'PHP-8.2' into PHP-8.3 2024-03-18 06:58:14 +00:00
David Carlier
868257a3de Fix GH-13727: macro generating invalid call test prototypes fixes.
autoconf/libtool generating code to test features missed `void` for
C calls prototypes w/o arguments.
Note that specific changes related to libtool have to be upstreamed.

Co-authored-by: Peter Kokot <petk@php.net>

close GH-13732
2024-03-18 06:53:39 +00:00
Máté Kocsis
56cf09f23a
Improve optimizer support for class constants (#13438)
The following optimizations are added:

- Constant folding of final class constants
- Type inference of typed class constants
2024-03-18 07:30:44 +01:00
Peter Kokot
0aadc7e7ff
Fix string concatenation in ZEND_JIT_SRC variable (#13740)
The += operator only works in bash shells and when using /bin/sh, for
example in Alpine Linux, the warning is thrown during configuration step

./configure: line 51396: ZEND_JIT_SRC+= jit/ir/ir_disasm.c: not found
2024-03-18 06:58:30 +01:00
Gina Peter Banyard
a648365fc0
ext/spl: Throw TypeError when overloaded SplObjectStorage::getHash() method does not return a string 2024-03-17 23:08:58 +00:00
Gina Peter Banyard
610c7a07b1
Move SplObjectStorage test to a folder 2024-03-17 23:08:47 +00:00
David Carlier
4c467e6eb8 ext/sockets: adding few constants for NetBSD.
SOCK_CONN_DGRAM (and its alias SOCK_DCCP) for connection orientated
datagram.

Close GH-13728
2024-03-17 21:44:22 +00:00
Nikita Popov
67184f5445
Fix PdoSqlite::loadExtension() test (#13736)
The test contained a syntax error and an incorrect use of loadExtension(), which returns void not bool.

Also install the necessary package in CI, so it gets tested there.
2024-03-17 22:27:09 +01:00
Niels Dossche
47b6eabe37 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-13685: Unexpected null pointer in zend_string.h
2024-03-17 18:38:44 +01:00
Niels Dossche
dab5f8c15c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13685: Unexpected null pointer in zend_string.h
2024-03-17 18:38:36 +01:00
Niels Dossche
aa34e0acb4 Fix GH-13685: Unexpected null pointer in zend_string.h
Regressed in 6fbf81c.

There is a missing error check on spl_filesystem_file_read_line(), which
means that if the line could not be read (e.g. because we're at the end
of the file), it will not set intern->u.file.current_line, which will
cause a NULL pointer deref later on.

Fix it by adding a check, and reintroducing the silent flag partially to
be able to throw an exception like it did in the past.

Closes GH-13692.
2024-03-17 18:37:52 +01:00
Niels Dossche
b955973818 Only register error handling when observable
Closes GH-13702.
2024-03-17 18:24:40 +01:00
Niels Dossche
9fd74cfc9d Use temporary variables to reduce memory stores 2024-03-17 18:21:59 +01:00
Niels Dossche
cbc421e163 Add fast path for ASCII bytes in UTF-8 validation 2024-03-17 18:21:59 +01:00
Bob Weinand
6f49474542 Merge branch 'PHP-8.3' of https://github.com/php/php-src 2024-03-17 03:17:15 +01:00
Bob Weinand
6c4e3c0f52
Use ZEND_API in zend_hrtime (#13288)
This allows actually calling zend_hrtime() from extensions on Windows.

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2024-03-17 03:09:08 +01:00