Commit Graph

118657 Commits

Author SHA1 Message Date
Christoph M. Becker
2393692937 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79596: MySQL FLOAT truncates to int some locales
2020-05-15 09:13:22 +02:00
Christoph M. Becker
844a1245ef Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79596: MySQL FLOAT truncates to int some locales
2020-05-15 09:11:44 +02:00
Christoph M. Becker
d1cd489a53 Fix #79596: MySQL FLOAT truncates to int some locales
We must not do locale aware float to string conversion here; instead
we using our `snprintf()` implementation with the `F` specifier.
2020-05-15 09:09:41 +02:00
Christoph M. Becker
3771d6f8a1 Merge branch 'PHP-7.4'
* PHP-7.4:
  [ci skip] Fix NEWS
2020-05-15 08:59:55 +02:00
Christoph M. Becker
f4c9f8b17b [ci skip] Fix NEWS
We add the missing release dates, the NEWS regarding the latest CVE
fixes, and move the entry for bug #79536 to 7.4.7 because it didn't
make it into 7.4.6.
2020-05-15 08:53:58 +02:00
Christoph M. Becker
f6ae728f56 Remove unused variable 2020-05-14 17:55:31 +02:00
Máté Kocsis
93640db4d5
Improve error message for deprecated methods 2020-05-14 17:23:31 +02:00
Bob Weinand
4bc1cf2928 Remove generated zend_jit_x86.c upon make distclean 2020-05-14 16:59:54 +02:00
Christoph M. Becker
5a17694304 Merge branch 'PHP-7.4'
* PHP-7.4:
  Check compatibility with proper runtime DLL
2020-05-14 15:59:34 +02:00
Christoph M. Becker
bfcee2c746 Check compatibility with proper runtime DLL
In practise, this likely does not matter, because usually these DLLs
are installed side by side, but still we should check the proper DLL.
2020-05-14 15:57:55 +02:00
Nikita Popov
e696732850 Merge branch 'PHP-7.4'
* PHP-7.4:
  Canonicalize bison error during ini parsing
2020-05-14 14:16:22 +02:00
Nikita Popov
3978d3a957 Canonicalize bison error during ini parsing
Bison 3.6 seems to use "end of file" rather than "$end" for this.
Force the same on older bison versions to be consistent.
2020-05-14 14:15:56 +02:00
Máté Kocsis
68527a7834
Add stubs for some SAPIs
For apache2handler, fpm, litespeed, phpdbg, specifically.
Partially implements GH-5295
2020-05-14 13:35:12 +02:00
Dmitry Stogov
161ee110bf Tracing JIT support for delayed call chain 2020-05-14 14:21:46 +03:00
Máté Kocsis
9198faa67f
Convert resource to object in Sysvmsg
Closes GH-5546
2020-05-14 12:56:06 +02:00
Nikita Popov
75bac16788 Avoid duplicating the proc_open cleanup logic
Use a slightly ugly "goto unreachable" pattern to share this code,
so we don't have to duplicate cleanup logic for the success and
the failure cases.
2020-05-14 10:35:33 +02:00
Alex Dowad
dc1496e4a3 Further refactoring of proc_open.c
This time a number of comments have been added to make it easy for new devs to understand
what is going on. Also adjusted error message to use colons rather than dashes.
2020-05-14 10:25:52 +02:00
Alex Dowad
b983580dd7 Don't leak memory if wrong resource type is passed to proc_open
proc_open can accept stream resources in the descriptorspec, like this:

    proc_open("command", array(0 => $resource), $pipes);

Previously, if a resource which was *not* of type "stream" was passed, proc_open would
return without freeing dynamically allocated memory. It's fixed now.
2020-05-14 10:25:37 +02:00
Alex Dowad
a84cd96e86 Add PTY support to proc_open (again after 16 long years)
Back in 2004, a feature was added to proc_open which allowed it to open a PTY,
connecting specific FDs in the child process to the slave end of the PTY and returning
the master end of the PTY (wrapped as a PHP stream) in the `$pipes` array. However,
this feature was disabled just about a month later. Little information is available
about why this was done, but from talking to the original implementer, it seems there
were portability problems with some rare flavors of Unix.

Re-enable this feature with a simplified implementation which uses openpty(). No
attempt is made to support PTYs if the platform does not have openpty(). The configure
script checks if linking with -lutil is necessary to use openpty(), but if anything
else is required, like including some special header or linking with some other library,
PTY support will be disabled.

The original PTY support for proc_open automatically daemonized the child process
(disassociating it from the TTY session and process group of the parent). However,
I don't think this is a good idea. Just because a user opens a child process in a
PTY, it doesn't mean they want it to continue running even when the parent process
is killed. Of course, if the child process is some kind of server, it will likely
daemonize itself; but we have no reason to preempt that decision.

It turns out that since 2015, there has been one test case for PTY support in
proc_open() in the test suite. This test was added in GitHub PR #1588
(https://github.com/php/php-src/pull/1588). That PR mentioned that the PHP
binary in the Debian/Ubuntu repositories is patched to *enable* PTY support. Checking
the Debian PHP repository (https://salsa.debian.org/php-team/php.git) shows that this
is still true. Debian's patch does not modify the implementation from 2004 in any
way; it just removes the #if 0 line which disables it.

Naturally, the test case is skipped if PTY support is not enabled. This means that ever
since it was added, every test run against the 'vanilla' PHP codebase has skipped it.

Interestingly, the test case which was added in 2015 fails on my Linux Mint PC... both
with this simplified implementation *and* when enabling the original implementation.
Investigation reveals the reason: when the child process using the slave end of the
PTY exits and its FDs are all closed, and all buffered data is read from the master
end of the PTY, any further attempt to read from the master end fails with EIO. The
test case seems to expect that reading from the master end will always return an
empty string if no data is available.

Likely this is because PHP's fread() was updated to report errors from the underlying
system calls only recently.

One way out of this dilemma: IF at least one FD referring to the slave end of the PTY is
kept open *in the parent process*, the failure with EIO will not occur even after the child
process exits. However, that would raise another issue: we would need a way to ensure the FD
will be closed eventually in long-running programs.

Another discovery made while testing this code is that fread() does not always return
all the data written to the slave end of the PTY in a single call, even if the data was
written with a single syscall and it is only a few bytes long.

Specifically, when the child process in the test case writes "foo\n" to the PTY, the parent
sometimes receives "foo" (3 bytes) and sometimes "foo\r\n" (5 bytes). (The "\r" is from the
TTY line discipline converting "\n" to "\r\n".) A second call to fread() does return the
remaining bytes, though sometimes all the data is read in the first call, and by the time
the second call is made, the child process has already exited. It seems that liberal use
of the @ operator is needed when using fread() on pipes.

Thanks to Nikita Popov for suggesting that we should just use openpty() rather than
grantpt(), unlockpt(), etc.
2020-05-14 10:25:37 +02:00
Nikita Popov
ae5ca5459f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix lcov genhtml: ERROR: cannot read [file]
  Properly detect CRC32 APIs on aarch64 from configure
2020-05-14 09:39:03 +02:00
Gerard Roche
ae1d4a820a Fix lcov genhtml: ERROR: cannot read [file]
lcov is emitting several errors for generated regex files that have no code
coverage data. The fix is to add the files to the lcov exlusion list.

This is not an issue for CI because it uses gcovr to generate code coverage.

The errors:

    Processing ext/date/lib/parse_date.gcda
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/parse_date.re
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/<stdout>
    geninfo: WARNING: some exclusion markers may be ignored
    Processing ext/date/lib/parse_tz.gcda
    Processing ext/date/lib/tm2unixtime.gcda
    Processing ext/date/lib/parse_iso_intervals.gcda
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/<stdout>
    geninfo: WARNING: could not open /home/code/vendor/php/php-src/parse_iso_intervals.re
    geninfo: WARNING: some exclusion markers may be ignored
    ...
    genhtml: ERROR: cannot read /home/code/vendor/php/php-src/parse_date.re
    Processing file /home/code/vendor/php/php-src/parse_date.re
    make: *** [Makefile:443: lcov-html] Error 2

Closes GH-5568.
2020-05-14 09:38:27 +02:00
Ondřej Surý
d4bebc874b Properly detect CRC32 APIs on aarch64 from configure
The CRC32 APIs are optional for armv8-a. They became mandatory since
armv8.1-a.

Closes GH-5564.
2020-05-14 09:38:05 +02:00
Jens de Nies
a4cc9d83a1 Removed pure zpp tests in the imap extension
Closes GH-5569.
2020-05-14 09:37:22 +02:00
Christoph M. Becker
69d46c3433 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix brittle shmop test
2020-05-13 23:31:09 +02:00
Christoph M. Becker
1892e3abaa Fix brittle shmop test
To solve bug #70886, the test uses random keys to prevent collisions;
however, this is not guaranteed, and as such it may even collide with
other tests in the shmop test suite.  The proper solution would be to
use a single key (which could be randomly generated), but to actually
`shmop_close()` after each `shmop_delete()`.  This would, however, not
work on Windows due to bug #65987.  Therefore we use three different
keys for now.
2020-05-13 23:25:28 +02:00
Nikita Popov
50a9f511cc Allow null callback to array_filter()
With same behavior as not passing it.
2020-05-13 17:24:13 +02:00
Dmitry Stogov
9122638ecd Set "hybrid_ret_counters" only after links to "function entry" traces. 2020-05-13 17:45:48 +03:00
Remi Collet
30077100a4 Revert "doc for enchant Object move"
This reverts commit 2c63324a4e.
2020-05-13 15:56:18 +02:00
Remi Collet
5318971bc5 Revert "convert enchant resources to objects of new classes - EnchantBroker - EnchantDict add OO interface deprecate enchant_broker_free* (use unset instead) deprecate ENCHANT_MYSPELL and ENCHANT_ISPELL constants"
This reverts commit 7db4c24a37.
2020-05-13 15:56:14 +02:00
Remi Collet
ea1bebbd41 Revert "add myself as enchant maintainer"
This reverts commit f987219c69.
2020-05-13 15:56:10 +02:00
Remi Collet
2c63324a4e doc for enchant Object move 2020-05-13 15:23:07 +02:00
Remi Collet
7db4c24a37 convert enchant resources to objects of new classes - EnchantBroker - EnchantDict add OO interface deprecate enchant_broker_free* (use unset instead) deprecate ENCHANT_MYSPELL and ENCHANT_ISPELL constants 2020-05-13 15:14:50 +02:00
Nikita Popov
87e6f93fd6 Assert on unknown type in zend_get_type_by_const() 2020-05-13 15:03:44 +02:00
Dmitry Stogov
fa919f9277 Fixed JIT with ON_HOT_COUNTERS trigger (opcache.jit=1235) 2020-05-13 16:00:25 +03:00
Nikita Popov
c6a6ca078b Use zend_zval_type_name() API where possible
Rather than zend_get_type_by_const(Z_TYPE_P()).
2020-05-13 14:56:05 +02:00
Nikita Popov
3f51d82bca Rename zend_zval_get_type() API
We have a bunch of APIs for getting type names and it's sometimes
hard to keep them apart ... make it clear that this is the one
you definitely do not want to use.
2020-05-13 14:56:05 +02:00
Máté Kocsis
256b7da356
Convert resource to object in XML-RPC extension
Closes GH-5457
2020-05-13 14:49:13 +02:00
Dmitry Stogov
98d8bcc13a Better trace_buffer packing 2020-05-13 15:45:42 +03:00
Alex Dowad
555489dd83 Honor script time limit when calling shutdown functions
A time limit can be set on PHP script execution via `set_time_limit` (or .ini file).
When the time limit is reached, the OS will notify PHP and `timed_out` and `vm_interrupt`
flags are set. While these flags are regularly checked when executing PHP code, once the
end of the script is reached, they are not checked while invoking shutdown functions
(registered via `register_shutdown_function`).

Of course, if the shutdown functions are implemented *in* PHP, then the interrupt flag
will be checked while the VM is running PHP bytecode and the timeout will take effect.
But if the shutdown functions are built-in (implemented in C), it will not.

Since the shutdown functions are invoked through `zend_call_function`, add a check of the
`vm_interrupt` flag there. Then, the script time limit will be respected when *entering*
each shutdown function. The fact still remains that if a shutdown function is built-in and
runs for a long time, script execution will not time out until it finishes and the
interpreter tries to invoke the next one.

Still, the behavior of scripts with execution time limits will be more consistent after
this patch. To make the execution time-out feature work even more precisely, it would
be necessary to scrutinize all the built-in functions and add checks of the `vm_interrupt`
flag in any which can run for a long time. That might not be worth the effort, though.

It should be mentioned that this patch does not solely affect shutdown functions, neither
does it solely allow for interruption of running code due to script execution timeout.
Anything else which causes `vm_interrupt` to be set, such as the PHP interpreter receiving
a signal, will take effect when exiting from an internal function. And not just internal
functions which are called because they were registered to run at shutdown; there are
other cases where a series of internal functions might run in the midst of a script. In
all such cases, it will be possible to interrupt the interpreter now.

Closes GH-5543.
2020-05-13 12:47:12 +02:00
Xinchen Hui
f06f260292 Revert "Fixed crash if jit.trigger is counter based with preload scripts"
This reverts commit 3d4e23aa92.
2020-05-13 18:35:00 +08:00
Xinchen Hui
ded0b34a48 Merge branch 'master' of git.php.net:/php-src
* 'master' of git.php.net:/php-src:
  Use new Fast ZPP macros for string|int parar types
  utime is always available on Windows
2020-05-13 18:23:55 +08:00
Xinchen Hui
3d4e23aa92 Fixed crash if jit.trigger is counter based with preload scripts 2020-05-13 18:22:29 +08:00
George Peter Banyard
1f05966a41 Use new Fast ZPP macros for string|int parar types
Closes GH-5512
2020-05-13 12:07:02 +02:00
George Peter Banyard
0e4c7b3264 utime is always available on Windows
Therefore drop useless preprocessor if check

Closes GH-5563
2020-05-13 12:05:29 +02:00
Xinchen Hui
f150b020c0 Merge branch 'master' of git.php.net:/php-src
* 'master' of git.php.net:/php-src:
  skip when mbstring missing (no warning)
2020-05-13 18:01:16 +08:00
Xinchen Hui
91b5571fcc Fixed #79582 (Crash seen when opcache.jit=1235 and opcache.jit_debug=2) 2020-05-13 18:00:16 +08:00
Remi Collet
ebdcdf39ed skip when mbstring missing (no warning) 2020-05-13 10:56:10 +02:00
Gerard Roche
ecc0a87ff2 run-tests: extract usage message
Put the usage message near the top of the script,
into a separate function.

Closes GH-5558.
2020-05-13 09:54:55 +02:00
Gerard Roche
10edee7f03 run-tests: cs fixes (cleanup)
I used php-cs-fixer to do the cs fixes. The configuration I used is
posted below. The reason I disabled some of the rules is because they
create too much noise and would make it difficult to review. But please
feel free to close this PR and run the php-cs-fixer yourself.

    <?php

    $config = PhpCsFixer\Config::create();
    $config->setRiskyAllowed(false);
    $config->setRules([
        '@PSR2' => true,
        '@Symfony' => true,
        'array_syntax' => false,
        'binary_operator_spaces' => false,
        'blank_line_before_statement' => false,
        'concat_space' => false,
        'increment_style' => false,
        'phpdoc_align' => false,
        'single_quote' => false,
        'trailing_comma_in_multiline_array' => false,
        'unary_operator_spaces' => false,
        'yoda_style' => false,
    ]);

    $finder = PhpCsFixer\Finder::create();
    $finder->in(getcwd());

    $finder->exclude('Zend');
    $finder->exclude('build');
    $finder->exclude('ext');
    $finder->exclude('pear');
    $finder->exclude('sapi');
    $finder->exclude('scripts');
    $finder->exclude('win32');

    $config->setFinder($finder);

    return $config;

Closes GH-5557.
2020-05-13 09:52:44 +02:00
Dmitry Stogov
7d66e4f323 Replace zend_jit_trace_info.loop_kind by zend_jit_trace_info.flags 2020-05-13 00:56:04 +03:00