Skip to content

Commit 53b329e

Browse files
authored
Fix GH-15101: _ir_RSTORE: Assertion `ctx->control' (#15153)
1 parent 28080dc commit 53b329e

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8180,6 +8180,8 @@ static int zend_jit_type_check(zend_jit_ctx *jit, const zend_op *opline, uint32_
81808180
if (!smart_branch_opcode || exit_addr) {
81818181
if (end_inputs) {
81828182
ir_MERGE_list(end_inputs);
8183+
} else if (exit_addr && !jit->ctx.control) {
8184+
ir_BEGIN(IR_UNUSED); /* unreachable block */
81838185
}
81848186
} else {
81858187
_zend_jit_merge_smart_branch_inputs(jit, true_label, false_label, true_inputs, false_inputs);

ext/opcache/tests/jit/gh15101.phpt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
--TEST--
2+
GH-15101: _ir_RSTORE: Assertion `ctx->control' failed
3+
--EXTENSIONS--
4+
opcache
5+
--INI--
6+
opcache.enable=1
7+
opcache.enable_cli=1
8+
opcache.file_update_protection=0
9+
opcache.revalidate_freq=0
10+
opcache.protect_memory=1
11+
--FILE--
12+
<?php
13+
class A {
14+
function test($context, $token) {
15+
if ($token instanceof DoctypeToken) {
16+
$this->processDoctypeToken($context, $token);
17+
}
18+
}
19+
private function processDoctypeToken(TreeBuilderContext $context, DoctypeToken $token): void
20+
{
21+
$publicId = $token->publicIdentifier;
22+
$systemId = $token->systemIdentifier;
23+
$name = $token->name;
24+
25+
if ($name !== 'html'
26+
|| $publicId !== null
27+
|| ($systemId !== null && $systemId !== 'about:legacy-compat')) {
28+
}
29+
30+
$doctype = new DocumentType($context->document, $name ?? '', $publicId ?? '', $systemId ?? '');
31+
}
32+
}
33+
class Document {
34+
}
35+
final class TreeBuilderContext {
36+
public $document;
37+
public function __construct() {
38+
$this->document = new Document;
39+
}
40+
}
41+
abstract class Node {
42+
public const DOCUMENT_TYPE_NODE = 10;
43+
44+
protected function __construct(Document $document, int $nodeType)
45+
{
46+
}
47+
}
48+
class DocumentType extends Node {
49+
public readonly string $name;
50+
public readonly string $publicId;
51+
public readonly string $systemId;
52+
53+
public function __construct(
54+
Document $document,
55+
string $name,
56+
string $publicId = '',
57+
string $systemId = '') {
58+
parent::__construct($document, self::DOCUMENT_TYPE_NODE);
59+
}
60+
}
61+
class DoctypeToken {
62+
public $publicIdentifier;
63+
public $name;
64+
public $systemIdentifier;
65+
}
66+
67+
$a = new A;
68+
$doc = new TreeBuilderContext();
69+
$t = new DoctypeToken();
70+
$t->name = "html";
71+
foreach ([$doc, $t] as $token) {
72+
$a->test($doc, $token);
73+
}
74+
?>
75+
DONE
76+
--EXPECT--
77+
DONE

0 commit comments

Comments
 (0)