1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 09:28:21 +02:00
Commit Graph

131115 Commits

Author SHA1 Message Date
Bob Weinand 8076ca2bcf Merge branch 'PHP-8.2' 2023-01-30 12:33:23 +01:00
Bob Weinand f732486c08 Merge branch 'PHP-8.1' into PHP-8.2 2023-01-30 12:33:06 +01:00
Bob Weinand 00be6e1aed Look at executing generator for fiber destructor behaviour 2023-01-30 12:32:53 +01:00
Bob Weinand 1679235f0f Merge branch 'PHP-8.2' 2023-01-30 12:13:52 +01:00
Bob Weinand e746b89bc9 Merge branch 'PHP-8.1' into PHP-8.2 2023-01-30 12:13:41 +01:00
Bob Weinand b9bca2dadb Fix resetting ZEND_GENERATOR_IN_FIBER flag
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2023-01-30 12:13:07 +01:00
Dmitry Stogov ea37abd412 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix type inference
2023-01-30 13:16:17 +03:00
Dmitry Stogov 55e3f73109 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix type inference
2023-01-30 13:16:05 +03:00
Dmitry Stogov 81607a62ca Fix type inference
Fixes oss-fuzz #55358
2023-01-30 13:15:05 +03:00
David Carlier 908d954de0 sockets updlite protocol support, with checksum coverage settings.
Close GH-10468
2023-01-29 18:19:54 +00:00
George Peter Banyard 231ffaf394 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect check in phar tar parsing
2023-01-29 17:17:32 +00:00
George Peter Banyard 08f654b590 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect check in phar tar parsing
2023-01-29 17:17:21 +00:00
Niels Dossche ec4939b170 Fix incorrect check in phar tar parsing
The entry.flags was used to check whether the entry has the directory
flag. The flags however were masked to only contain the permissions. We
need to check the mode, before the permission masking, instead of the
flags to check whether it is a directory.

Closes GH-10464

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-29 17:14:12 +00:00
Aaron Piotrowski ff84598055 Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-10437: Set active fiber to null on bailout (#10443)
2023-01-28 10:18:51 -06:00
Aaron Piotrowski 5e1b9666a9 [ci skip] NEWS 2023-01-28 10:18:12 -06:00
Aaron Piotrowski 0c4aee464a Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10437: Set active fiber to null on bailout (#10443)
2023-01-28 10:16:04 -06:00
Aaron Piotrowski 284c29328e Fix GH-10437: Set active fiber to null on bailout (#10443) 2023-01-28 10:13:58 -06:00
Arnaud Le Blanc 306a72add4 Add test for GH-10405 2023-01-28 11:49:14 +01:00
Niels Dossche dc6fbec037 Fix missing zend_shared_alloc_unlock() (#10405)
This code was refactored and the unlock was forgotten.
The following assertion is triggered in debug mode:
  zend_shared_alloc_lock: Assertion `!(accel_globals.locked)' failed.
And in release mode this likely deadlocks.
Fix this by re-adding the unlock.
2023-01-28 11:48:46 +01:00
Arnaud Le Blanc 479b47c6f0 Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  [ci skip] NEWS
  Fix overflow check in OnUpdateMemoryConsumption (#10456)
  Prevent dtor of generator in suspended fiber (#10462)
2023-01-27 19:40:16 +01:00
Arnaud Le Blanc cfb6e82cbd [ci skip] NEWS 2023-01-27 19:37:27 +01:00
Arnaud Le Blanc 6c22dea3c1 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  Fix overflow check in OnUpdateMemoryConsumption (#10456)
  Prevent dtor of generator in suspended fiber (#10462)
2023-01-27 19:37:01 +01:00
Arnaud Le Blanc a24ac59e55 [ci skip] NEWS 2023-01-27 19:36:28 +01:00
Niels Dossche d7de73b551 Fix overflow check in OnUpdateMemoryConsumption (#10456)
memsize is a signed long, therefore the check against the
(*un*signed long maximum) / 1024² will allow too large values. This check worked
correctly in d4b3f89c53 where it checked against the maximum signed
value, but was broken in 003346c450. Fix it by changing ZEND_ULONG_MAX
to ZEND_LONG_MAX.
2023-01-27 19:33:58 +01:00
Arnaud Le Blanc 1173c2e64a Prevent dtor of generator in suspended fiber (#10462)
Generators that suspended a fiber should not be dtor because they will be
executed during the fiber dtor.

Fiber dtor throws an exception in the fiber's context in order to unwind and
execute finally blocks, which will also properly dtor the generator.

Fixes GH-9916
2023-01-27 19:32:25 +01:00
Arnaud Le Blanc ebf26af71a Merge branch 'PHP-8.2'
* PHP-8.2:
  Handle non-INDIRECT symbol table entries in zend_fiber_object_gc() (#10386)
2023-01-27 10:55:40 +01:00
Arnaud Le Blanc ab2097df48 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Handle non-INDIRECT symbol table entries in zend_fiber_object_gc() (#10386)
2023-01-27 10:55:30 +01:00
Arnaud Le Blanc 9830204213 Handle non-INDIRECT symbol table entries in zend_fiber_object_gc() (#10386)
Fixes GH-10340
2023-01-27 10:52:42 +01:00
Tim Düsterhus 64d9080534 random: Fix off-by-one in fast path selection of Randomizer::getBytesFromString() (#10449)
With a single byte we can choose offsets between 0x00 and 0xff, thus 0x100
different offsets. We only need to use the slow path for sources of more than
0x100 bytes.

The previous version was correct with regard to the output expectations, it was
just slower than necessary. Better fix this now while we still can before being
bound by our BC guarantees with regard to emitted sequences.

This also adds a test to verify the behavior: For powers of two we never reject
any values during rejection sampling, we just need to mask off the unneeded
bits. Thus we can specifically verify that the number of calls to the engine
match the expected amount. We also verify that all the possible values are
emitted to make sure the masking does not remove any required bits. For inputs
longer than 0x100 bytes we need trust the `range()` implementation to be
unbiased, but still verify the number of engine calls and perform a basic
output check.
2023-01-26 23:28:34 +01:00
Alex Dowad 8f318c383d Add specialized UTF-8 validation function for hosts with no SSE2/AVX2 support
In a GitHub thread, Michael Voříšek and Kamil Tekiela mentioned that
the PCRE2 function `pcre_match` can be used to validate UTF-8, and that
historically it was more efficient than mbstring's `mb_check_encoding`.

`mb_check_encoding` is now much faster on hosts with SSE2, and much
faster again on hosts with AVX2. However, while all x86-64 CPUs support
at least SSE2, not all PHP users run their code on x86-64 hardware.
For example, some use recent Macs with ARM CPUs.

Therefore, borrow PCRE2's UTF-8 validation function as a fallback for
hosts with no SSE2/AVX2 support. On long UTF-8 strings, this code is
50% faster than mbstring's existing fallback code.
2023-01-26 20:58:24 +02:00
Ilija Tovilo 02bd52b5a8 Implement dynamic class const fetch
https://wiki.php.net/rfc/dynamic_class_constant_fetch

Closes GH-9793
2023-01-26 16:46:34 +01:00
K f56dc76890 [skip ci] Add explanatory comments to _zend_op structure
Closes GH-7522

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-26 13:26:04 +00:00
Alex Dowad 63c50cc87e Add AVX2-accelerated version of mb_check_encoding for UTF-8 only
From some local benchmarks which I ran, the AVX2-based version is about
2.8x faster than the SSE2-based version on long (~10,000 byte) strings,
1.6x faster on medium (~100 byte) strings, and just about the same
on very short strings.

I followed the example of the code in the 'standard' module, using
preprocessor directives so that the code can be compiled in any of
4 ways:

1) With no AVX2 support at all (for example, when PHP is compiled for
   CPU architectures other than AMD64)
2) For CPUs with AVX2 only (for example, when PHP is built with
   CCFLAGS='-march=native' on a host which implements AVX2)
3) With runtime detection of AVX2 performed by the dynamic linker;
   this requires a dynamic linker which supports the STT_GNU_IFUNC
   symbol type extension to the ELF binary standard. This is true of
   glibc's dynamic linker, as of late 2009.
4) With runtime detection of AVX2 performed by the module init function.
   The detection is done by checking the output of CPUID and then a
   function pointer is set accordingly. In this case, all calls to the
   UTF-8 validation routine are indirect calls through that
   function pointer.
2023-01-26 09:49:58 +02:00
Alex Dowad d14ed12783 Adjust code to finish validating remaining 0-8 bytes at end of UTF-8 string
This code is a few percent faster for short UTF-8 strings. For long
(~10,000 byte) strings, it is also consistently faster on my local
microbenchmarks, but by less than 1%.
2023-01-26 09:49:58 +02:00
David Carlier b0ad9dff3e Merge branch 'PHP-8.2' 2023-01-25 20:59:19 +00:00
David Carlier fe9b622e7a zend extension build warning fix.
clang is more picky in this case but at least it makes it more consistent overall.
2023-01-25 20:59:08 +00:00
David CARLIER 90b0e77921 GNU compilers remove hot attribute proposal. (#8922)
While the cold attribute has its place, the hot one however
does one have real justification for use, even more so with
modern toolchains.
2023-01-25 19:51:22 +00:00
Derick Rethans 48db3423a5 Merge branch 'PHP-8.2' 2023-01-25 10:50:32 +00:00
Derick Rethans 2c8ea44ff4 Merge branch 'ossfuzzer-fixes' into PHP-8.2 2023-01-25 10:50:24 +00:00
Derick Rethans 639bfbc217 Sync timelib to 2022.05 to address OSS Fuzzer issues 2023-01-25 10:49:48 +00:00
Dmitry Stogov f6fc0fd97b Add missing type guard 2023-01-25 12:10:19 +03:00
Tim Düsterhus 6c8ef1d997 random: Reduce variable scopes in CSPRNG (#10426)
* random: Convert the urandom loop into a while() loop

This allows us to more easily reduce the scope of `n` in a future commit and
now matches the getrandom(2) loop.

* random: Move the errno reset immediately above the getrandom(2) call

* random: Reduce the scope of `n` in the CSPRNG

* random: Declare `n` outside of preprocessor branch
2023-01-25 09:15:48 +01:00
George Peter Banyard 3fe8b090d3 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect check in zend_internal_call_should_throw()
  Fix incorrect check in cs_8559_5 in map_from_unicode()
  Fix incorrect page_size check
2023-01-25 00:12:32 +00:00
Niels Dossche 972c74c300 Fix incorrect check in zend_internal_call_should_throw()
This debug code is part of arginfo validation. This validation will
never trigger properly because the OR operation makes the first if
always true. Fix it by changing to an AND.

Closes GH-10417

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-25 00:12:13 +00:00
George Peter Banyard 0d9bf101c4 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect check in cs_8559_5 in map_from_unicode()
  Fix incorrect page_size check
2023-01-25 00:10:56 +00:00
Niels Dossche a8c8fb2564 Fix incorrect check in cs_8559_5 in map_from_unicode()
The condition `code == 0x0450 || code == 0x045D` is always false because
of an incorrect range check on code.
According to the BMP coverage in the encoding spec for ISO-8859-5
(https://encoding.spec.whatwg.org/iso-8859-5-bmp.html) the range of
valid characters is 0x0401 - 0x045F (except for 0x040D, 0x0450, 0x045D).
The current check has an upper bound of 0x044F instead of 0x045F.
Fix this by changing the upper bound.

Closes GH-10399

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-25 00:08:28 +00:00
Niels Dossche b7a158a19b Fix incorrect page_size check
The current check always evaluated to false because if `!page_size`
is true, then `page_size & (page_size - 1)` equals `0 & (0 - 1)` which
is always 0. The if condition is meant to check if page_size is zero or
not a power of two, thus we must change the AND to an OR to fix this
issue.

Closes GH-10427

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-25 00:06:56 +00:00
Tim Düsterhus 8cb807f4c5 Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS (#10442)
2023-01-24 23:21:06 +01:00
Tim Düsterhus a8ecfc8a9b Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS (#10442)
2023-01-24 23:20:16 +01:00
Niels Dossche 40da9961f2 [ci skip] NEWS (#10442) 2023-01-24 23:19:21 +01:00