Commit Graph

837 Commits

Author SHA1 Message Date
Nikita Popov
003c13d7bc Fix iterable return type optimization 2019-09-19 17:21:00 +02:00
Tyson Andre
29bced9521 Fix opcache return type for get_headers in zend_func_info
https://www.php.net/manual/en/function.get-headers.php#refsect1-function.get-headers-examples
shows that it will return string keys when the second argument is
non-zero. I've verified that this is the case.

This bug was there since the initial commit in c88ffa9a56.

Closes GH-4702.
2019-09-17 12:08:29 +02:00
Tyson Andre
9c3b7ccda5 Fix opcache return type for hash_update_stream
It can return false if the resource type is wrong.

```
php > var_export(hash_update_stream(hash_init('md5'),
        imagecreate(1,1)));

Warning: hash_update_stream(): supplied resource is not a valid stream
resource in php shell code on line 1
false
```

The return types were initially added in
c88ffa9a56
2019-09-03 09:23:39 +02:00
Tyson Andre
1e82a2d659 Also fix signature for passthru
Backported from a1a8d14485
https://www.php.net/manual/en/function.passthru.php#refsect1-function.passthru-returnvalues

`passthru()` is false with invalid args
`passthru('command')` is null.
2019-08-26 11:13:26 +02:00
Tyson Andre
f5bccc0eb5 Fix opcache optimizer info for time_nanosleep
This can also return an array. See
https://www.php.net/manual/en/function.time-nanosleep.php#refsect1-function.time-nanosleep-returnvalues

> If the delay was interrupted by a signal, an associative array will be
returned with the components:
>
> - seconds - number of seconds remaining in the delay
> - nanoseconds - number of nanoseconds remaining in the delay

Sending a SIGUSR1 to the below program would trigger this behavior.

```
pcntl_signal(\SIGUSR1, function ($signo, $signinfo) {
    echo "Handling a signal $signo\n";
});
echo "Sleeping for 100 seconds\n";
var_export(time_nanosleep(100, 0));
```

The incomplete signature existed since c88ffa9a5.
No phpt tests existed for time_nanosleep returning an array
2019-08-26 11:13:26 +02:00
Nikita Popov
4eeb41d1ea Fixed bug #77191 2019-08-13 11:19:58 +02:00
Nikita Popov
5846e85283 Backport fe_reset_rw case 2019-07-05 12:06:52 +02:00
Nikita Popov
c353f17d42 Fix inference for compound object op on dim 2019-07-05 11:39:42 +02:00
Nikita Popov
59dfaa3f99 Fix type inference of SEND_UNPACK with empty array
An empty array will not be turned into an array of references.
This violated the invariant than an array has values iff it has
keys.
2019-05-28 16:40:56 +02:00
Dmitry Stogov
56a5d0bd91 Fixed CFG construction for SWITCH opcodes 2019-04-03 03:09:03 +03:00
Nikita Popov
54bf8c820f Fixed bug #77743 2019-03-18 10:49:53 +01:00
Nikita Popov
3f00c9367d Fixed bug #77691
We cannot replace an op1_def opcode with an ASSIGN, if it also has
a used res_def. Usually this doesn't happen because the res_def use
can be eliminated first. The example is a case where operand replacement
on the res_def use fails.
2019-03-04 13:11:12 +01:00
Nikita Popov
2cfb09caa7 Fix inference warning about missing key type 2019-02-22 11:55:16 +01:00
Tyson Andre
cf56832d00
Properly check for array_replace_recursive in sccp.c
Due to a typo, this code used to check for array_merge_recursive
twice.
2019-02-03 08:40:21 +01:00
Nikita Popov
1165a9068c Don't swap operands of ZEND_MUL
If this is used with operator overloading, then the operation does
not necessarily commute (for example, matrix multiplication).
2019-01-08 09:37:49 +01:00
Nikita Popov
17f8b9fb36 Fixed bug #77215
Remove invalid assertion: A block can have multiple switch frees,
so if we don't do live range block splitting, it is not necessarily
true that the free is located at the start of a block.
2018-11-28 20:08:39 +01:00
Nikita Popov
4daa413898 Fixed bug #77092
Weird that this worked for so long, probably because nearly all
ext/standard functions use fast ZPP rather than ordinary ZPP.
2018-11-02 14:29:03 +01:00
Nikita Popov
902ec36710 Merge branch 'PHP-7.1' into PHP-7.2 2018-10-25 16:43:36 +02:00
Nikita Popov
f1ceec5533 Fixed bug #77058
Account for the fact that undef must be interpreted as null for
the purposes of INC/DEC inference.
2018-10-25 16:37:41 +02:00
Nikita Popov
e7153e8a2f Improve "narrowing" error message
By including the opcode name.
2018-10-25 16:36:23 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Peter Kokot
7f6387b59a Trim trailing whitespace in source code files 2018-10-13 14:12:55 +02:00
Nikita Popov
cfdd828163 Fixed bug #76796 2018-09-07 14:02:03 +02:00
Nikita Popov
34deda13a8 Merge branch 'PHP-7.1' into PHP-7.2 2018-06-30 19:50:40 +02:00
Nikita Popov
2eb6a541a9 Fix typo in compound dim assign op inference
Thankfully a harmless one, just makes inference results worse.
2018-06-30 19:50:07 +02:00
Xinchen Hui
f31ba7cb53 Fixed bug #76477 (Opcache causes empty return value) 2018-06-15 16:31:31 +08:00
Nikita Popov
4c083e7a66 Merge branch 'PHP-7.1' into PHP-7.2 2018-04-27 22:23:55 +02:00
Nikita Popov
6738d19fb8 Fix bug #76281
Make sure we keep the smart-branch inhibiting NOP even if there
are multiple NOPs in sequence.
2018-04-27 22:21:59 +02:00
Nikita Popov
2c602be7c8 Merge branch 'PHP-7.1' into PHP-7.2 2018-04-27 17:02:01 +02:00
Nikita Popov
279ba58edb Fixed bug #76275
* Adjust IS_SERIALIZED() check to account for potential empty
  allocations at the end of the memory region.
* Deallocate empty allocation if all try/catch elements have been
  removed in the block pass (similar to what we do if all live
  ranges have been eliminated).
2018-04-27 17:01:35 +02:00
Nikita Popov
3306577797 Followup fix for bug #75729
The case of overloaded substr() with 3 arguments was not handled.
2018-03-24 13:15:59 +01:00
Xinchen Hui
4758164ac5 Fixed bug #76094 (Access violation when using opcache) 2018-03-15 11:17:00 +08:00
Dmitry Stogov
5574562f8f Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Revert "More accurate symbolic constraints oferflow/unserflow handling (better fix for bug #76074)."
2018-03-13 11:03:57 +03:00
Dmitry Stogov
0643c7ab4d Revert "More accurate symbolic constraints oferflow/unserflow handling (better fix for bug #76074)."
This reverts commit 44ba557de5.
2018-03-13 11:03:45 +03:00
Dmitry Stogov
575f5002c0 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  More accurate symbolic constraints oferflow/unserflow handling (better fix for bug #76074).
2018-03-13 10:45:53 +03:00
Dmitry Stogov
44ba557de5 More accurate symbolic constraints oferflow/unserflow handling (better fix for bug #76074). 2018-03-13 10:44:53 +03:00
Bob Weinand
cfd0979be5 Merge branch 'PHP-7.1' into PHP-7.2 2018-03-10 15:21:16 +01:00
Bob Weinand
9c6df8a238 Fix bug #76074 (opcache corrupts variable in for-loop) 2018-03-10 15:20:45 +01:00
Nikita Popov
500632ac13 Fix pfsockopen() func info 2018-02-18 17:42:12 +01:00
Nikita Popov
c0abab5fca Fix ZEND_SL range inference
This is a bit tricker than right shifts because shifting in the
sign bit flips the sign. The computed bounds are not tight.
2018-02-18 17:42:12 +01:00
Nikita Popov
202989edf8 Fix ZEND_SR range inference
Handle out-of-range RHS correctly.
2018-02-18 17:42:12 +01:00
Nikita Popov
40ff001381 Fix constant() func info
Since PHP 5.6 this can also be an array.
2018-02-18 17:42:11 +01:00
Nikita Popov
ae837db8cf Handle overloaded GMP operators in type inference 2018-02-18 15:33:30 +01:00
Nikita Popov
39974dd65d Disable negative range inference
The negative range inference implementation does not work correctly,
and it's not clear right now how it can be fixed. As such, disable
it entirely for now.
2018-02-18 15:33:28 +01:00
Nikita Popov
846e8a3ec9 Fix COUNT range inference
count() on objects may return a negative number :(
2018-02-17 23:18:30 +01:00
Nikita Popov
fa7c23ba27 Fix hash_init() and hash_copy() func info
These functions were switched to use objects instead of resources.
2018-02-17 23:18:29 +01:00
Nikita Popov
acb9426a6b Fix curl_multi_close() func info
Returns false on failure
2018-02-17 23:18:29 +01:00
Nikita Popov
8bdf9905da Fix get_object_vars() func info
Numeric keys will be converted to integer nowadays.
2018-02-17 23:18:29 +01:00
Nikita Popov
1a50a50bcf Add RC flags in init_func_return_info 2018-02-17 23:18:29 +01:00
Nikita Popov
fd5644cd0b Fix array_values() and array_keys() func info
Can return RCN for empty/packed arrays
2018-02-17 23:18:28 +01:00