Skip to content

Commit 8fc28e9

Browse files
committed
[skip-ci] More test and assertion to try to figure out wth is going on
Seems like a pointer not allocated via ZMM gets into the arena????
1 parent 5bea1b0 commit 8fc28e9

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Eval Class definition should not leak memory when using compiled traits
3+
--FILE--
4+
<?php
5+
6+
trait TraitCompiled {
7+
public function bar(): self { return new self; }
8+
}
9+
10+
const EVAL_CODE = <<<'CODE'
11+
class A {
12+
use TraitCompiled;
13+
}
14+
CODE;
15+
16+
eval(EVAL_CODE);
17+
18+
$a1 = new A();
19+
$a2 = $a1->bar();
20+
var_dump($a2);
21+
22+
?>
23+
DONE
24+
--EXPECT--
25+
object(A)#2 (0) {
26+
}
27+
DONE

Zend/tests/type_declarations/relative_class_types/relative_type_in_evaled_trait.phpt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,21 @@ Eval code should not leak memory when using traits
44
<?php
55

66
const EVAL_CODE = <<<'CODE'
7-
trait TraitExample {
8-
public function bar(): self|C|D { return new self; }
9-
}
10-
class B {
11-
use TraitExample;
7+
trait TraitEval {
8+
public function bar(): self { return new self; }
129
}
1310
CODE;
1411

1512
eval(EVAL_CODE);
1613

1714
class A {
18-
use TraitExample;
15+
use TraitEval;
1916
}
2017

2118
$a1 = new A();
2219
$a2 = $a1->bar();
2320
var_dump($a2);
2421

25-
//$b1 = new B();
26-
//$b2 = $b1->bar();
27-
//var_dump($b2);
28-
2922
?>
3023
DONE
3124
--EXPECT--

Zend/zend_opcode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ ZEND_API void destroy_zend_function(zend_function *function)
110110

111111
ZEND_API void zend_type_release(zend_type type, bool persistent) {
112112
if (ZEND_TYPE_HAS_LIST(type)) {
113+
ZEND_ASSERT((!persistent && !ZEND_TYPE_USES_ARENA(type)) && "User defined list types must be arena allocated");
113114
zend_type *list_type;
114115
ZEND_TYPE_LIST_FOREACH(ZEND_TYPE_LIST(type), list_type) {
115116
zend_type_release(*list_type, persistent);

0 commit comments

Comments
 (0)