Commit Graph

58346 Commits

Author SHA1 Message Date
Christoph M. Becker
703cac33db
Fix GH-7867: FFI::cast() from pointer to array is broken
Casting from pointer to array is special, so we must not fall back to
the general FFI casting.  There is a particular issue regarding the
size comparison, namely that the pointer size is always 8 for 64bit
architectures, but the size of an array is determined by its
declaration, so as is casting a pointer to an array with more than 8
elements would fail, but casting to an array with less than 9 elements
succeeds, but the internal pointer would point to some arbitrary
memory.

We fix this by properly supporting the cast.  An alternative would be
to deny this kind of cast generally, since it is not necessarily safe.
However, FFI isn't necessarily safe anyway.

We also check pointer/array type compatibility when casting.

Co-authored-by: Dmitry Stogov <dmitry@zend.com>

Closes GH-7876.
2022-01-10 23:58:39 +01:00
Dmitry Stogov
1f58365438 Fix type inference
Fixes oss-fuzz #43367
2022-01-10 21:53:35 +03:00
Dmitry Stogov
698ac23711 Fixed NAN handling in SCCP
Fixes oss-fuzz #43341
2022-01-10 19:39:19 +03:00
Dmitry Stogov
71d6501346 Added test 2022-01-10 16:05:40 +03:00
Dmitry Stogov
b80d30d821 Fix type inference for assign to string offset with invalid index.
Fixes oss-fuzz #43277
2022-01-10 16:03:54 +03:00
Dmitry Stogov
4170d41a66 JIT: Fix incorrect FETCH_THIS elimination
Fizex oss-fuzz #43159
2022-01-10 15:37:36 +03:00
Benjamin Eberlei
2f6a06ccb0
Fix #81430: Attribute instantiation leaves dangling pointer
By switching attribute constructor stackframe to be called via
trampoline the stack allocation is not causing dangling pointers
in the zend_observer API anymore.

Co-Authored-By: Florian Sowade <f.sowade@suora.com>
Co-Authored-By: Christopher Becker <cmbecker69@gmx.de>
Co-Authored-By: Dmitry Stogov <dmitry@zend.com>

Closes GH-7885.
2022-01-10 12:40:15 +01:00
Christoph M. Becker
9781085782
Fix ODBC test which may not properly clean up
If these tests fail with a fatal error, they won't properly clean up,
which likely causes other tests to fail as (several ODBC tests use the
`odbcTEST` database and tables or stored procedures named `FOO`).  This
is particularly annoying during development, where you would need to
clean up manually.

We fix this by moving the cleanup code to the --CLEAN-- section, so
that this code is executed no matter what.

Closes GH-7886.
2022-01-07 19:23:57 +01:00
David Carlier
09165ace37
Fix ext/sockets build on Haiku
The `SOCK_RDM` datagram option is unsupported on Haiku; instead `ifreq`
has direct access to `ifr_index`.

Closes GH-7849.
2022-01-04 14:10:50 +01:00
Christoph M. Becker
d963b3f015
mysqli_next_result_no_repeat_error.phpt must not use --EXTENSIONS--
This is only properly supported as of PHP 8.1.0[1], and may cause
spurious test failures for older versions[2].

[1] <https://github.com/php/php-src/pull/6787>
[2] <https://ci.appveyor.com/project/php/php-src/builds/42044075/job/tk4138s43p1953hx>
2021-12-31 00:24:56 +01:00
Kamil Tekiela
49512b6b36
Fix formatting in the new mysqli test 2021-12-30 19:25:32 +00:00
NathanFreeman
b3903515bf
Fix bug where large bigints may be truncated
Unless stringified results are requested, we need to parse large
bigints as unsigned, to avoid wrap-around behavior.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-7837.
2021-12-30 19:07:36 +01:00
Dmitry Stogov
206bcff50d iSeparate tests 2021-12-28 16:56:23 +03:00
Dmitry Stogov
fd879e6fe4 JIT: Fix array clobbering by user error handler
Gixes oss-fuzz #43055
2021-12-28 16:51:03 +03:00
Dmitry Stogov
de358f856f Fix reference contig inference
Fixes oss-fuzz #43032
2021-12-28 09:57:03 +03:00
Christoph M. Becker
ee610947ce
Revert "Fix zend_observer_fcall_end_all() accessing dangling pointers"
This reverts commit 76e2a8380e.  Cf.
<76e2a8380e (r62560239)>.
2021-12-27 21:08:51 +01:00
Florian Sowade
76e2a8380e
Fix zend_observer_fcall_end_all() accessing dangling pointers
This may happen, when the execute_data was allocated on the stack.  We
ensure that the runtime cache pointer is not NULL before dereferencing
it.

This is a partial fix for bug 81430.

Closes GH-7665.
2021-12-27 18:19:13 +01:00
Christoph M. Becker
7f0a1e2f2d
Fix bug40228*.phpt conflict
Both tests use the same directory structure; we avoid that by
extracting to separate subdirectories.

Closes GH-7831.
2021-12-26 23:23:56 +01:00
Christoph M. Becker
5005445994
Mark curl tests using http2.golang.org as XFAIL
http2.golang.org/serverpush has been retired[1], so we need to come up
with an alternative.  Until then, we mark the relevant tests as XFAIL
(although bug77535.phpt passes, what might be an indication that the
test needs further revision).  To avoid waiting for the timeout, we
also unconditionally skip these tests for now.

[1] <https://github.com/golang/go/issues/49301>

Closes GH-7829.
2021-12-26 22:27:15 +01:00
Christoph M. Becker
e76ddbd2f6
Prevent strict interpretation of tentative definition
This header declaration is never supposed to be interpreted as
definition; otherwise, the handlers are not properly initialized, what
happens, for instance, with ASan instrumented MSVC builds.

Closes GH-7827.
2021-12-26 16:41:25 +01:00
Christoph M. Becker
fd3fc5c193
Fix GH-7826: Inconsistent argument name in hash_hmac_file and hash_file
Like `hash_file()`, `hash_hmac_file()` expects a filename, and not some
string data.  Fixing this now, constitutes a (hopefully small) BC break
though.

Closes GH-7828.
2021-12-26 12:55:53 +01:00
Christoph M. Becker
b4ba65dd9d
Fix chunk_split_variation*_32bit.phpt for Windows
Both tests fail on Windows for slightly different reasons, what appears
to be legit, and as such we fix the test expectations.

Closes GH-7830.
2021-12-26 12:05:52 +01:00
Dmitry Stogov
2b81156f2a Fix memory leak in SCCP
Fixes oss-fuzz #42878
2021-12-24 13:10:22 +03:00
David Carlier
3f0bb67361
Avoid void* arithmetic in sockets/multicast.c on NetBSD
On NetBSD, ifconf.ifc_buf member, unlike most of platforms, is a void
pointer.

We also fix the cpuinfo declarations with empty parameter lists.

Closes GH-7819.
2021-12-23 16:17:30 +01:00
Christophe Coevoet
096a01c905
[ci skip] Update the min curl version in the sync-constants.php script
PHP 8.0 bumped the min curl version to 7.29.0

Closes GH-7805.
2021-12-23 13:43:32 +01:00
Christoph M. Becker
c5f4ee50ab
$context parameter of get_headers() is nullable
Closes GH-7813.
2021-12-23 11:47:20 +01:00
David Carlier
80b02275bb
socket cmsg credential test fixes, "backporting" from the FreeBSD PR. 2021-12-21 07:27:59 +01:00
David Carlier
51647eb23e
socket: ancillary credentials build fix for non linux systems.
for systems using SO_PASSCRED sockopt flag but not using ucred struct.
2021-12-21 07:25:43 +01:00
Dmitry Stogov
cb10ac1d53 Fixed compilation warning 2021-12-21 00:02:45 +03:00
Dmitry Stogov
6d5922bed5 JIT: Fix incorrect JIT prologur size for CLANG/x86 build
Fixes oss-fuzz #42724
2021-12-20 23:52:46 +03:00
Dmitry Stogov
e004e844f7 Fix incorrect optimization of ASSIGN_OP that may lead to memory leak
Fixes oss-fuzz #42506
2021-12-20 15:06:32 +03:00
Dmitry Stogov
7c674e1aa7 JIT: Fix register clobbering
Fixes oss-fuzz #42657
2021-12-20 12:48:48 +03:00
Dmitry Stogov
f18bb2477f Fix type inference for INIT_ARRAY with invalid index
Fixes oss-fuzz #42568
2021-12-20 11:40:11 +03:00
Yifan Tong
3587e13ab3
Fix FILTER_FLAG_NO_RES_RANGE flag
`2001:10::/28` is a reserved IPv6 range. But there's a typo in GH-7476,
which caused IPv6 address like `240b:0010::1` will be filtered by the
flag `FILTER_FLAG_NO_RES_RANGE`.

http://www.faqs.org/rfcs/rfc6890.html

Closes GH-7790.
2021-12-19 16:24:34 +01:00
Dmitry Stogov
66306030ad JIT: Fix incorrect type store elimination
Fixes oss-fuzz #42388
2021-12-17 12:31:48 +03:00
Christoph M. Becker
49380b59d2
Fix #81679: Tracing JIT crashes on reattaching
When a new process reattaches to OPcache, tracing JIT causes segfaults,
because each new process allocates its own `zend_jit_traces` and
`zend_jit_exit_groups` in SHM, although these need to be shared between
all processes.

We solve that by only allocating these structs for the first process,
and store the pointers in `accel_shared_globals`, so we can reassign
them when a new process reattaches.

Closes GH-7776.
2021-12-15 15:37:23 +01:00
Dmitry Stogov
cd8e6f5f7b Preloading: don't remove INCLUDE_OE_EVAL nstructions with used result 2021-12-14 11:36:33 +03:00
Dmitry Stogov
fe320e83ae Tracing JIT: Fix reference counting
Fixes oss-fuzz #42225
2021-12-13 16:28:45 +03:00
Dmitry Stogov
cbc0b1afeb Fix array clobering by user error handler
Fixes oss-fuzz #42234
2021-12-13 14:59:30 +03:00
Dmitry Stogov
230de7721f Fix incorrect optimization that leads to memory leak
Fixes oss-fuzz #42221
2021-12-13 13:08:05 +03:00
Dmitry Stogov
e79dbe1124 JIT: Fix crash during compilation of function with incompletely constructed SSA
Fixes oss-fuzz #42200
2021-12-13 11:49:51 +03:00
Christoph M. Becker
c435e67746
Fix GH-7765: php_oci_cleanup_global_handles segfaults at second call
We must not use the TSRM accessor macros in GINIT and GSHUTDOWN, but
rather use the passed pointers directly.  For simplicity, we inline
`php_oci_cleanup_global_handles()`, and also the `PHP_OCI_CALL()`
macros; the latter are unlikely to be needed here, but don't hurt.

Closes GH-7766.
2021-12-12 22:38:00 +01:00
Christoph M. Becker
0b3a937670
Fix GH-7759: Incorrect return types for hash() and hash_hmac()
`hash()` and `hash_hmac()` never return `false`; only `hash_file()` and
`hash_hmac_file()` return `false` in case the data cannot be read.

Closes GH-7760.
2021-12-12 15:39:55 +01:00
SATO Kentaro
778513f605
Fix error message allocation of PDO PgSQL
Closes GH-7723.
2021-12-12 15:17:36 +01:00
Christoph M. Becker
2c2b0abd4a
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix openssl_x509_checkpurpose_basic.phpt
2021-12-12 14:27:07 +01:00
Christoph M. Becker
98175fc7f1
Fix openssl_x509_checkpurpose_basic.phpt
This test fails because san-cert.pem and san-ca.pem have expired.  We
fix that by using the CertificateGenerator to generate temporary certs
during the test run.  Since san-cert.pem and san-ca.pem have been
identical, we only generate one certificate.

Closes GH-7763.
2021-12-12 14:26:17 +01:00
Dmitry Stogov
6f42c073cf Remove range inference for booleans.
Range inference for bolleans and longs comparison was incorrect.

Fizes oss-fuzz #fuzz-42161.php
2021-12-10 14:32:47 +03:00
Dmitry Stogov
0ac3d78d7d Fix incorrect JMP optimization
Fixes oss-fuzz #42155
2021-12-10 01:39:28 +03:00
Christoph M. Becker
efb901ebed
Skip bug_36798.phpt for PDO_DBLIB
For some reason, this test fails now with "Incorrect syntax near ''.
[SELECT '�' as test FROM test WHERE id = '1']", so we skip it.
2021-12-07 20:24:15 +01:00
Aliaksandr Bystry
daf79e2d91
Fix #75917: SplFileObject::seek broken with CSV flags
Closes GH-7697.
2021-12-06 18:59:48 +01:00
Dmitry Stogov
7b629afe4e Fixed incorrect DCE of a constructor call
Fixez oss-fuzz #42049
2021-12-06 15:59:30 +03:00
Dmitry Stogov
c29f6baaee JIT: Fix incorrect elimination of type store
Fixes oss-fuzz #41995
2021-12-06 14:22:07 +03:00
Dmitry Stogov
aa7280264e Fix refcount inferemce ($a += $a returns old array with RCN)
Fixes oss-fuzz #41670
2021-12-06 11:30:03 +03:00
Dmitry Stogov
c9901aa594 Add missing "return" 2021-12-03 13:52:10 +03:00
Dmitry Stogov
4a5c05a49d ws 2021-12-03 13:40:01 +03:00
Dmitry Stogov
1d054b3fa7 Fix array object clobbering by user error handler
Fixes oss-fuss #41605 and #41610
2021-12-03 13:35:28 +03:00
Dmitry Stogov
2515e788bc JIT: Fix register clobbering
Fixes oss-fuzz #41621
2021-12-03 11:13:50 +03:00
Dmitry Stogov
c4ee66856e Tracing JIT: Fixed Zend/tests/str_offset_008.phpt failure 2021-12-02 23:47:36 +03:00
Dmitry Stogov
2fde308fc6 JIT: Fix ASSIGN_DIM_OP with undefined variable and index and user error handler, throwing an exception
Fixes oss-fuzz #39422
2021-12-02 22:19:48 +03:00
Dmitry Stogov
94286cd596 Fix yet another indirect string modification by error handler problem 2021-12-02 16:16:54 +03:00
Dmitry Stogov
37ac707cac Add missing zend_string_release_ex(tmp, 0) and cleanup
- use GC_DELREF() instead of zend_string_release_ex()
- add expectations for exceptional cases
- replace IS_ARRAY_IMMUTABLE by IS_STR_INTERNED
2021-12-02 11:18:08 +03:00
Dmitry Stogov
df16da3697 Fixed ext/bz2/tests/005.phpt test failure introduesed by 09547c64c2 2021-12-02 10:32:45 +03:00
Dmitry Stogov
4595a57e99 Fix clobering of operand by error handler in assignment to string offset (optimization and JIT support) 2021-12-02 01:20:17 +03:00
Dmitry Stogov
e7b31f57ec JIT: Fix incorrect code produced for BOOL_NOT and [double, undef] operand
Fixes oss-fuzz #41531
2021-11-30 20:36:52 +03:00
Dmitry Stogov
c1036194d6 JIT: Fix incorrect reference counting inference
Fixes oss-fuzz #40747
2021-11-30 12:58:54 +03:00
Dmitry Stogov
6e1fe96962 JIT: Fix uninitialized result of ASSIGN_DIM[_OP] after clobbering array by user error handler
Fixes oss-fuzz #41208
2021-11-30 11:40:18 +03:00
Dmitry Stogov
86430e8e01 Fixed type inference (it's safe to ignore reference counting narrowing) 2021-11-29 23:32:52 +03:00
Dmitry Stogov
aff115547f JIT: Fix exception handling when next array element is already occupied
Fixes oss-fuzz #41408
2021-11-29 21:44:00 +03:00
Christoph M. Becker
816aa20391
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #74604: Out of bounds in php_pcre_replace_impl
2021-11-29 19:15:20 +01:00
Christoph M. Becker
712fc54e85
Fix #74604: Out of bounds in php_pcre_replace_impl
Trying to allocate a `zend_string` with a length only slighty smaller
than `SIZE_MAX` causes an integer overflow; we make sure that this
doesn't happen by catering to the maximal overhead of a `zend_string`.

Closes GH-7597.
2021-11-29 19:12:55 +01:00
Dmitry Stogov
d955415114 JIT: Fix named arguments handling
Fixes oss-fuzz #41486
2021-11-29 18:39:50 +03:00
Dmitry Stogov
8f4cfe04eb JIT: Fix named arguments handling
Fixes oss-fuzz #41486
2021-11-29 18:37:49 +03:00
Christoph M. Becker
f3bd24a200
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81659: stream_get_contents() may unnecessarily overallocate
2021-11-29 14:48:11 +01:00
Christoph M. Becker
31749aac62
Fix #81659: stream_get_contents() may unnecessarily overallocate
Since we're going to read from the current stream position anyway, the
`max_len` should be the size of the file minus the current position
(still catering to potentially filtered streams).  We must, however,
make sure to cater to the file position being beyond the actual file
size.

While we're at, we also fix the step size in the comment, which is 8K.

A further optimization could be done for unfiltered streams, thus
saving that step size, but 8K might not be worth it.

Closes GH-7693.
2021-11-29 14:46:09 +01:00
Dmitry Stogov
297117bbc5 Disable type narrowing optimization when we contruct SSA for JIT
This also revets incorrect fix introduced in f9518c3850
2021-11-29 15:51:54 +03:00
Dmitry Stogov
49f44e7ffc JIT: Fixed use-after-free caused by shift by negative number
Fixes oss-fuzz #41192
2021-11-25 22:21:44 +03:00
Christoph M. Becker
179030d167
Fix #81649: imap_(un)delete accept sequences, not single numbers
As such, the parameter name `$message_num` is utmost misleading; it
should be `$message_nums` as for other functions.

Closes GH-7686.
2021-11-25 18:29:43 +01:00
Dmitry Stogov
f9518c3850 Fixed incorrect narrowing to double
Fixes oss-fuzz #41223
2021-11-25 15:14:04 +03:00
Dmitry Stogov
3c53a9fd73 Fixed incorrect refcountion inference for BW_NOT
BW_NOT for emtpy string returns empty string

Fixes oss-fuzz #41280
2021-11-25 13:51:56 +03:00
Dmitry Stogov
f302430c72 Fixed incorrect DCE for ADD_ARRAY_ELEMENT instruction
DCE might remove INIT_ARRAY instruction but then keep the related
ADD_ARRAY_ELEMENT, becuse its both operands need to be freed.

Fixes oss-fuzz #41309
2021-11-25 13:33:26 +03:00
Remi Collet
f6621037a0
add missing cond. 2021-11-25 10:14:30 +01:00
Remi Collet
e713890d36
fix gdImagePngCtxEx call with system libgd 2021-11-25 08:27:07 +01:00
Christoph M. Becker
9237055141
"Export" relevant GD macros
For parity with non Windows systems, we should `AC_DEFINE` these macros
so that they are defined in config.w32.h instead of directly passed to
the compiler.  This allows extensions which have ext/gd as dependency
to check for these macros.  E.g. ext/ps does this[1], and fails to
build on Windows, because `HAVE_GD_BUNDLED` isn't defined.

[1] <https://github.com/steinm/ps/blob/RELEASE_1_4_4/ps.c#L34>

Closes GH-7680.
2021-11-24 18:23:28 +01:00
Nikita Popov
be271f277e Fix bug #81652
We need to check not only for defs but also for uses of the
variable.
2021-11-24 15:18:31 +01:00
Christoph M. Becker
b29e85a0da
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #75725: ./configure: detecting RAND_egd
2021-11-22 14:13:52 +01:00
Дилян Палаузов
60fe575ce3
Fix #75725: ./configure: detecting RAND_egd
Closes GH-7668.
2021-11-22 14:11:07 +01:00
Nikita Popov
bc6ec0a109 Clarify that preg_match_all() cannot return null 2021-11-18 10:36:35 +01:00
Dmitry Stogov
9dd3e8be8a JIT: Fixed memory leak in Zend/tests/concat_002.phpt introduced by fac78ee760 2021-11-17 18:43:39 +03:00
Dmitry Stogov
fac78ee760 JIT: Fixed memory leak 2021-11-17 13:59:35 +03:00
Dmitry Stogov
48a65fef6f JIT: Fixed memory lieak 2021-11-17 12:48:56 +03:00
David Carlier
fb3e646f6b OpenBSD ZTS build fix
Closes GH-7661.
2021-11-17 10:20:05 +01:00
Nikita Popov
18a0d46a1b Safely reassign array in usort()
Make sure to destroy the old value only after assigning the new
one. Otherwise we may try to double free, e.g. if GC runs during
this dtor.

This caused an assertion failure in phpro/grumphp and is likely
the cause for bug #81603 as well.

(cherry picked from commit 6f38acfaf9)

(I applied this to the wrong base branch at first...)
2021-11-16 10:15:47 +01:00
Nikita Popov
6f38acfaf9 Safely reassign array in usort()
Make sure to destroy the old value only after assigning the new
one. Otherwise we may try to double free, e.g. if GC runs during
this dtor.

This caused an assertion failure in phpro/grumphp and is likely
the cause for bug #81603 as well.
2021-11-16 10:13:46 +01:00
Dmitry Stogov
fc35a6b93c Tracing JIT: Fixed abstract stack consistency for [QM_]ASSIGN of CV to itself 2021-11-15 23:25:16 +03:00
Dmitry Stogov
85066fd88e Tracing JIT: Fixed failure on non-optimized op_arrays (op_array->T may be above ssa->vars_count) 2021-11-15 14:44:01 +03:00
Nikita Popov
4a2656327d Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix bug #81618: Correct dns_get_record on FreeBSD
2021-11-15 10:00:36 +01:00
Matt
45f52285f6 Fix bug #81618: Correct dns_get_record on FreeBSD
Modify dns_get_record to test for records result based on dns_errno to
accommodate modern FreeBSD, for which res_nsearch() does not update
h_errno directly. Add new php_dns_errno macro, and have it consult
statp->res_h_errno when OS has res_nsearch().

Closes GH-7655.
2021-11-15 10:00:07 +01:00
Dmitry Stogov
292d76d8a4 JIT: Fixed reference-counting inference 2021-11-15 10:39:58 +03:00
Stanislav Malyshev
0ef1dfc9f6
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #79971: special character is breaking the path in xml function
2021-11-14 23:29:27 -08:00
Stanislav Malyshev
ca87d46a3e
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79971: special character is breaking the path in xml function
2021-11-14 23:28:13 -08:00
Christoph M. Becker
f15f8fc573
Fix #79971: special character is breaking the path in xml function
The libxml based XML functions accepting a filename actually accept
URIs with possibly percent-encoded characters.  Percent-encoded NUL
bytes lead to truncation, like non-encoded NUL bytes would.  We catch
those, and let the functions fail with a respective warning.
2021-11-14 23:24:33 -08:00
Dmitry Stogov
64fde17042 Fixed test 2021-11-12 22:48:50 +03:00
Dmitry Stogov
12d02e6227 Fixed incorrect guard elimination 2021-11-12 21:00:08 +03:00
Dmitry Stogov
5380b415a2 JIT: Partially fix handling of exceptions thrown in interrupt handlers 2021-11-11 21:14:17 +03:00
Dmitry Stogov
fa0b84a06b Partially fix handling of exceptions thrown in interrupt handlers 2021-11-11 20:59:56 +03:00
Dmitry Stogov
64915775a7 JIT: Fixed incorrect MOD into BW_AND optimization 2021-11-10 21:14:41 +03:00
Dmitry Stogov
3081423706 Tracing JIT: Fixed register allocation
In case of side exit on ADD/SUB/MUL overflow source registers must be kept unchanged
2021-11-10 20:04:25 +03:00
Dmitry Stogov
3dba5566ce Tracing JIT: Fixed incorrect assumption about in-memeory zval type 2021-11-10 16:46:09 +03:00
Dmitry Stogov
45683703f1 JIT: Fixed memory leak 2021-11-10 12:49:20 +03:00
Dmitry Stogov
203c1b807e Tracing JIT: Fixed incorrect tracing type inference
There are some cases when IS_VAR/IS_TMP_VAR variables are set to IS_UNDEF.
TODO: It would be better to switch to IS_NULL in master.
2021-11-10 11:10:44 +03:00
Nikita Popov
a551b08307 Add string return type to __toString() of internal classes
Same as with userland classes, automatically add a string return
type to __toString() methods in internal classes, so the signature
is compatible with Stringable.
2021-11-09 10:17:26 +01:00
Dmitry Stogov
535a0553e8 Fixed incorrect reference counter inference 2021-11-08 20:54:17 +03:00
Dmitry Stogov
8fe808207f JIT: Fixed incorrect guard elimination 2021-11-08 20:08:39 +03:00
Nikita Popov
53df29bc29 Drop pi nodes for both old/new pred in replace_predecessor
We also need to drop pi nodes for new_pred here, as the pi node
restriction for new_pred is not necessarily true for control
coming from old_pred as well.

Fixes oss-fuzz #40782.
2021-11-08 14:56:42 +01:00
Dmitry Stogov
e868ded6ef Don't call _zend_hash_index_find() for packed arrays 2021-11-08 13:13:23 +03:00
Dmitry Stogov
7bf63243e1 JIT: Fixed incorrect guard elimination 2021-11-08 12:28:36 +03:00
Nikita Popov
9b2a3c1c4f Fix stubs for bzerr* functions
These can return false if the stream is not a bz2 stream. Also
emit a warning in this case, this should not be failing silently.
2021-11-05 11:09:20 +01:00
Nikita Popov
b302bfabe7 Implement Stringable automatically for internal classes
Requiring all internal classes (including those from 3rd-party
extensions) to implement Stringable if they provide __toString()
is too error prone. Case in point, our _ZendTestClass test class
was not doing so, resulting in preloading test failures after
recent changes.

Instead we automatically implement Stringable, the same as we do
for userland classes. We still allow explicit implementations,
but ignore them (normally they would result in an error due to
duplicate interface implementation). Finally, we need to be
careful about not trying to implement Stringable on Stringable
itself.

In some cases this changes the interface order, in particular the
automatic Stringable implementation will now come first.
2021-11-05 10:22:04 +01:00
Christoph M. Becker
f22f4afd84
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #71316: libpng warning from imagecreatefromstring
2021-11-04 11:19:24 +01:00
Christoph M. Becker
1919c4b44d
Fix #71316: libpng warning from imagecreatefromstring
We backport the respective upstream fix[1] to our bundled libgd.

[1] <636100b928>

Closes GH-7615.
2021-11-04 11:16:45 +01:00
Nikita Popov
4b9fbc6627 Fixed bug #81587
iterator_funcs_ptr may be null for Iterators with custom
get_iterator. Ideally MultipleIterator would make use of get_iterator,
but this would require a large implementation change.
2021-11-04 10:34:52 +01:00
Dmitry Stogov
34d22acc7e Tracing JIT: Fixed incorrect guard elimination 2021-11-03 23:37:00 +03:00
Dmitry Stogov
66d93c63ff Fixed type inference for FETCH_DIM_W without use 2021-11-03 19:44:38 +03:00
Derick Rethans
88f99c9c1d Revert "Updated to version 2021.5 (2021e)"
This reverts commit a93ff1df20.
2021-11-03 16:13:05 +00:00
Derick Rethans
4ec9d07cc3 Updated to version 2021.5 (2021e) 2021-11-03 15:49:25 +00:00
Derick Rethans
7c9c722b53 Updated to version 2021.5 (2021e) 2021-11-03 15:49:24 +00:00
Derick Rethans
a93ff1df20 Updated to version 2021.5 (2021e) 2021-11-03 15:49:23 +00:00
George Peter Banyard
84524afb9e
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix Bug #81588 TokyoCabinet driver leaks memory
2021-11-03 15:01:41 +00:00
George Peter Banyard
96dd310c54
Fix Bug #81588 TokyoCabinet driver leaks memory 2021-11-03 14:57:47 +00:00
Nikita Popov
a6d14f1143 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  CLDR 40a0 uses a lowercase "temp" instead of "Temp" in ICU >= 70.1
  Accommodate changes to canonicalized forms in ICU >= 70.1
  Change UBool to bool for equality operators in ICU >= 70.1
2021-11-02 16:15:25 +01:00
Ben Ramsey
c7a2441e93 CLDR 40a0 uses a lowercase "temp" instead of "Temp" in ICU >= 70.1
Refer to:
49dda34fb1
2021-11-02 16:15:19 +01:00
Ben Ramsey
52cda6fc43 Accommodate changes to canonicalized forms in ICU >= 70.1
Refer to:
01e1adc9e4
2021-11-02 16:11:29 +01:00
Ben Ramsey
81b3f95622 Change UBool to bool for equality operators in ICU >= 70.1
Refer to:
- 633438f8da
- f6325d49ba
2021-11-02 16:07:51 +01:00
Dmitry Stogov
2605911272 Tracing JIT: Fixed reference counting when escape because of IS_UNDEF element (test) 2021-11-01 22:19:10 +03:00
Dmitry Stogov
d7ac39b02d Tracing JIT: Fixed reference counting when escape because of IS_UNDEF element 2021-11-01 22:14:12 +03:00
Dmitry Stogov
5c43e0c0ee Fixed incorrect assumption about reference counting 2021-11-01 20:28:05 +03:00
Dmitry Stogov
f1e6a7d83d JIT: Fixed numeric string index handling 2021-11-01 18:50:32 +03:00
Dmitry Stogov
cd32b47235 JIT: Fixed register allocation in case of integer overflow 2021-11-01 16:46:41 +03:00
Nikita Popov
2e29817005 Handle FETCH_DIM_R after FETCH_DIM_FUNC_ARG in inference
This can happen if a call is optimized, but FETCH_DIM_FUNC_ARG
cannot be converted to FETCH_DIM_R because it uses an UNUSED op2,
which is not supported by FETCH_DIM_R.

Fixes oss-fuzz 6144185837682688.
2021-11-01 14:26:36 +01:00
Nikita Popov
f8ec5a1d4c Fix range inference hang
We shouldn't switch from range to no range for ZEND_DIV and instead
explicitly return an overflowing range. Otherwise the range will
not actually get updated during widening, and we'll perform
essentially infinite narrowing.

Fixes oss-fuzz #40566.
2021-11-01 12:31:34 +01:00
Christoph M. Becker
6e6a8443a8
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76167: mbstring may use pointer from some previous request
2021-10-25 12:39:57 +02:00
Christoph M. Becker
d3d6d7906e
Fix #76167: mbstring may use pointer from some previous request
We must not reuse per-request memory across multiple requests, so this
check triggered during RINIT makes no sense.  As explained in the bug
report[1], it can be even harmful, if some request startup fails, and
the pointers refer to already freed memory in the next request.

[1] <https://bugs.php.net/76167>

Closes GH-7604.
2021-10-25 12:37:28 +02:00
Dmitry Stogov
29c8c1e955 Tracing JIT: Fixed possible endless loop when escape from ZEND_CALL_TOP frame 2021-10-25 12:10:25 +03:00
Christopher Jones
3e9b53f2ec
Fix tests for method camel case change 2021-10-25 14:31:00 +11:00
Christopher Jones
51f1cacf7a
Fix tests for method camel case change 2021-10-25 14:17:28 +11:00
Dmitry Stogov
d3251632ad Tracing JIT: Fixed incorrect assumption about in-memeory zval type 2021-10-22 14:38:38 +03:00
Dmitry Stogov
c7e974fc4e Tracing JIT: Fixed incorrect assumtion about temporary variable types clobbered by *_ROPE instructions 2021-10-21 21:35:57 +03:00
Kamil Tekiela
c9d509b668
Revert "Fix bug GH-1 (mysqli_sql_exception->sqlstate is inaccessible)"
This reverts commit 64fca5c5f0.
2021-10-21 19:01:01 +01:00
Kamil Tekiela
64fca5c5f0
Fix bug GH-1 (mysqli_sql_exception->sqlstate is inaccessible) 2021-10-21 18:51:16 +01:00
Bob Weinand
345f46ff29 Fix weakmap API test
Apparently under some targets the address can evaluate to an address with the most significant bit set. (displays as negative number)
2021-10-21 19:31:37 +02:00
Remi Collet
a6f5c2dc8b
fix for pcre2 10.38 2021-10-21 13:37:26 +02:00
Bob Weinand
471102edcd Add ZEND_API for weakmap functionality via zend_weakrefs_hash_add/del
Closes GH-7600.
2021-10-21 13:34:22 +02:00
Remi Collet
56495ac031
fix for pcre2 10.38 2021-10-21 13:33:35 +02:00
Nikita Popov
decf906a90 Remove bug76738.phpt
The test contains PII in the base64-encoded part and is way too
complicated to be useful. I'd try to reduce it, but I can't tell
what it's actually supposed to test.
2021-10-21 10:40:12 +02:00
Dmitry Stogov
b69c6ba9df Use right frame 2021-10-20 23:50:33 +03:00
Dmitry Stogov
95c0dfc57f JIT: Fixed megamorphic call detection 2021-10-20 22:16:25 +03:00
Dmitry Stogov
38626dbaad JIT: Fixed memory leak 2021-10-20 10:38:47 +03:00
Dmitry Stogov
6bd5271c62 Fixed incorrect optimization that may cause JIT assertion 2021-10-18 23:18:52 +03:00
Dmitry Stogov
d3063c02c6 Tracing JIT: Fixed memory leak 2021-10-18 22:14:53 +03:00
Dmitry Stogov
e59d0a7151 JIT: Fixed DASM_S_RANGE_VREG error 2021-10-18 17:58:42 +03:00
Dmitry Stogov
13d1244575 Tracing JIT: Fixed ADD with two references to arrays 2021-10-18 17:26:36 +03:00
Dmitry Stogov
6021e72143 Tracinf JIT: Prevnt generation code for instruction that with cyclic dependency
e.g. $a[] += $a is compiled into ASSIGN_DIM_OP+OP_DATA, where OP_DATA.op1_use depends on ASSIGN_DIM_OP.op1_def
2021-10-18 16:53:45 +03:00
Christoph M. Becker
fc886694d3
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
2021-10-15 19:11:26 +02:00
Christoph M. Becker
866adb122a
Fix #81500: Interval serialization regression since 7.3.14 / 7.4.2
While it may not be desired, `DateInterval::$f` supports negative
values, at least with regard to calculations.  We still need to guard
from assigning double values which are out of range for signed 64bit
integers (which would be undefined behavior).  zend_dval_to_lval() does
this by returning `0` instead of triggering UB.  This way we can avoid
setting the invalid marker, which doesn't work as expected anyway.

We must not do that only for unserialization, but also when the property
is set in the first place.

We need to adapt some of the existing tests wrt. this behavior.  In
particular, we check for an arbitrary value in bug79015.phpt, to cater
to differences between 32bit and 64bit architectures.

Closes GH-7575.
2021-10-15 19:08:07 +02:00
Máté Kocsis
ca219d7d27
Fix 2nd param name of pg_send_execute()
Closes GH-7576
2021-10-13 14:14:47 +02:00
Remi Collet
6d0d5227d8
bump zip ext version 2021-10-13 11:53:02 +02:00
Nikita Popov
53f89219ab Fix bug #81521
The current error message is incorrect -- the problem here is not
that the property is invalid, but that these methods are unusable
prior to loading data, same as read().
2021-10-12 16:42:32 +02:00
Nikita Popov
9ebe8494b8 Don't replace tmp with cv in YIELD argument
For by-ref generators, these may have different behavior.

Fixes oss-fuzz 6059739298004992.
2021-10-12 14:26:53 +02:00
Christoph M. Becker
845a67feb5
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81424: PCRE2 10.35 JIT performance regression
2021-10-12 14:21:09 +02:00
Christoph M. Becker
788a701e22
Fix #81424: PCRE2 10.35 JIT performance regression
We backport the respective upstream fix[1] to our bundled pcre2lib plus
the follow-up fix[2] for a functional regression.

[1] <dc5f966635>
[2] <e7af7efaa1>

Closes GH-7573.
2021-10-12 14:19:22 +02:00
Máté Kocsis
2127b49c65
String default values are enclosed in quotes rather than apostrophes 2021-10-12 09:51:20 +02:00
Máté Kocsis
17fa9b77bd
Fix the return type of imagecolorexactalpha() 2021-10-12 09:51:13 +02:00
Dmitry Stogov
a4c41d45cd Fixed type inference for COPY_TMP 2021-10-11 16:56:07 +03:00
Dmitry Stogov
ccdda69a18 JIT: Fixed usage of incorrect specialized zval destructor 2021-10-11 13:00:23 +03:00
Dmitry Stogov
ed8ec9d71e Fixed type inference (ASSIGN_OP with typed reference may cause type conversion) 2021-10-11 10:48:49 +03:00
Nikita Popov
df940a6dc3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81494
2021-10-08 15:00:51 +02:00
Nikita Popov
fcabe693ba Fixed bug #81494
Use the proper error reporting mechanism rather than throwing a
warning. This requires something of a hack because we don't have
direct access to the connection object at this point.
2021-10-08 15:00:10 +02:00
Derick Rethans
b230593b0e Merge branch 'PHP-7.4' into PHP-8.0 2021-10-08 13:52:18 +01:00
Derick Rethans
9733d49e14 Remove now superfluous tests due to changes in tzdata 2021-10-08 13:51:21 +01:00
Dmitry Stogov
bbd875268a JIT: Fixed incorrect double/long register hinting 2021-10-08 15:46:49 +03:00
Derick Rethans
32c0850b4a Revert "Updated to version 2021.3 (2021c)"
This reverts commit e81554c6e6.
2021-10-08 13:12:50 +01:00
Derick Rethans
c55b41d658 Updated to version 2021.3 (2021c) 2021-10-08 12:54:53 +01:00
Derick Rethans
8a61f1ece6 Updated to version 2021.3 (2021c) 2021-10-08 12:54:52 +01:00
Derick Rethans
e81554c6e6 Updated to version 2021.3 (2021c) 2021-10-08 12:54:50 +01:00
Dmitry Stogov
b279de416e JIT: Fixed extension handling 2021-10-08 14:06:32 +03:00
Dmitry Stogov
45b127ad4a Flush error messages emitted during preloading 2021-10-08 12:34:25 +03:00
Dmitry Stogov
7cea20f937 JIT: Fixed FETCH_LIST_R on string 2021-10-07 22:13:39 +03:00
Dmitry Stogov
b47a48ff80 Fixed bug #81512 (Unexpected behavior with arrays and JIT) 2021-10-07 21:24:38 +03:00
Nikita Popov
56c9ea1881 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix failing PDO PgSQL test
2021-10-07 20:11:26 +02:00
Nikita Popov
c0cbf3a6eb Fix failing PDO PgSQL test
This now prints an additional

> CONTEXT:  unnamed portal parameter $1 = ''

on azure, presumably as a result of a version update or configuration
change. Strip this additional line from the error info, the same as
already done in one other place in the test.
2021-10-07 20:10:45 +02:00
Nikita Popov
b564113756 Check exception after undef var notice
For simple assignments, we may not emit an exception check elsewhere,
so perform it directly after the undef var notice.
2021-10-07 16:54:26 +02:00
Nikita Popov
08c29a657d Handle undefined dim in assign_dim_helper
Not only the value can be undefined here, but the offset as well.
2021-10-07 15:35:16 +02:00
Nikita Popov
455837139e Set opline before calling undef op helper 2021-10-07 14:38:02 +02:00
Dmitry Stogov
a743fd7633 JIT: Fixed wrong comparison skip 2021-10-07 15:27:56 +03:00
Dmitry Stogov
6ab36fb6f9 JIT: Fixed incorrect reference handling in PRE_INC/DEC_OBJ 2021-10-07 14:34:18 +03:00
Dmitry Stogov
cd45bd0a81 JIT: Fixed incorrect code generation for JMPZ 2021-10-07 13:48:28 +03:00
Nikita Popov
c69ffa8f84 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #54350
2021-10-07 11:46:10 +02:00
Nikita Popov
1519770288 Fixed bug #54350
Don't allow calling fclose() on the stream while in the user
filter callback. This is basically the same protection as xp_ssl
streams use during callback invocations.

There are more issues in this general area (e.g. stack overflow
on stream_filter_remove), but this addresses freeing the stream
during the filter callback invocation at least.
2021-10-07 11:44:41 +02:00
Dmitry Stogov
8a0873020a JIT: Fixed NaN handling 2021-10-06 16:35:33 +03:00
Dmitry Stogov
f681f9075c JIT: Fixed register clobbering 2021-10-06 12:10:39 +03:00