Skip to content

Commit faf1567

Browse files
committed
Fixed bug #80839 (PHP problem with JIT)
1 parent fddd0ac commit faf1567

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
. Fixed bug #80847 (CData structs with fields of type struct can't be passed
1010
as C function argument). (Nickolas Daniel da Silva, Dmitry)
1111

12+
- Opcache:
13+
. Fixed bug #80839 (PHP problem with JIT). (Dmitry)
14+
1215
01 Apr 2021, PHP 8.0.4
1316

1417
- Core:

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5221,6 +5221,9 @@ static int zend_jit_concat_helper(dasm_State **Dst,
52215221
| add r4, 12
52225222
|.endif
52235223
}
5224+
/* concatination with empty string may increase refcount */
5225+
op1_info |= MAY_BE_RCN;
5226+
op2_info |= MAY_BE_RCN;
52245227
| FREE_OP op1_type, op1, op1_info, 0, opline
52255228
| FREE_OP op2_type, op2, op2_info, 0, opline
52265229
|5:
@@ -5247,6 +5250,9 @@ static int zend_jit_concat_helper(dasm_State **Dst,
52475250
|.if not(X64)
52485251
| add r4, 12
52495252
|.endif
5253+
/* concatination with empty string may increase refcount */
5254+
op1_info |= MAY_BE_RCN;
5255+
op2_info |= MAY_BE_RCN;
52505256
| FREE_OP op1_type, op1, op1_info, 0, opline
52515257
| FREE_OP op2_type, op2, op2_info, 0, opline
52525258
if (may_throw) {

ext/opcache/tests/jit/bug80839.phpt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
Bug #80839: PHP problem with JIT
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.jit_buffer_size=1M
7+
opcache.jit=function
8+
--SKIPIF--
9+
<?php require_once('skipif.inc'); ?>
10+
--FILE--
11+
<?php
12+
$a = null; // the problem only occurs when set to NULL
13+
test($a, 'y');
14+
15+
function test($str, $pad) {
16+
$x = $str . str_repeat($pad, 15); // $x now contains "yyyyyyyyyyyyyyy"
17+
var_dump($x);
18+
19+
$gft = new gft();
20+
$gft->info(33);
21+
22+
// $x has been changed ????
23+
// $x contains what was echoed in the function 'info'
24+
var_dump($x);
25+
}
26+
class gft {
27+
private $strVal = 'abcd ';
28+
public function info($info, $prefix = ' Info:') {
29+
echo $this->strVal.$prefix.serialize($info).'aaaa';
30+
echo "\n";
31+
}
32+
}
33+
?>
34+
--EXPECT--
35+
string(15) "yyyyyyyyyyyyyyy"
36+
abcd Info:i:33;aaaa
37+
string(15) "yyyyyyyyyyyyyyy"

0 commit comments

Comments
 (0)