Skip to content

Fix GH-15101: _ir_RSTORE: Assertion `ctx->control' #15153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -8180,6 +8180,8 @@ static int zend_jit_type_check(zend_jit_ctx *jit, const zend_op *opline, uint32_
if (!smart_branch_opcode || exit_addr) {
if (end_inputs) {
ir_MERGE_list(end_inputs);
} else if (exit_addr && !jit->ctx.control) {
ir_BEGIN(IR_UNUSED); /* unreachable block */
}
} else {
_zend_jit_merge_smart_branch_inputs(jit, true_label, false_label, true_inputs, false_inputs);
Expand Down
77 changes: 77 additions & 0 deletions ext/opcache/tests/jit/gh15101.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
--TEST--
GH-15101: _ir_RSTORE: Assertion `ctx->control' failed
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.revalidate_freq=0
opcache.protect_memory=1
--FILE--
<?php
class A {
function test($context, $token) {
if ($token instanceof DoctypeToken) {
$this->processDoctypeToken($context, $token);
}
}
private function processDoctypeToken(TreeBuilderContext $context, DoctypeToken $token): void
{
$publicId = $token->publicIdentifier;
$systemId = $token->systemIdentifier;
$name = $token->name;

if ($name !== 'html'
|| $publicId !== null
|| ($systemId !== null && $systemId !== 'about:legacy-compat')) {
}

$doctype = new DocumentType($context->document, $name ?? '', $publicId ?? '', $systemId ?? '');
}
}
class Document {
}
final class TreeBuilderContext {
public $document;
public function __construct() {
$this->document = new Document;
}
}
abstract class Node {
public const DOCUMENT_TYPE_NODE = 10;

protected function __construct(Document $document, int $nodeType)
{
}
}
class DocumentType extends Node {
public readonly string $name;
public readonly string $publicId;
public readonly string $systemId;

public function __construct(
Document $document,
string $name,
string $publicId = '',
string $systemId = '') {
parent::__construct($document, self::DOCUMENT_TYPE_NODE);
}
}
class DoctypeToken {
public $publicIdentifier;
public $name;
public $systemIdentifier;
}

$a = new A;
$doc = new TreeBuilderContext();
$t = new DoctypeToken();
$t->name = "html";
foreach ([$doc, $t] as $token) {
$a->test($doc, $token);
}
?>
DONE
--EXPECT--
DONE
Loading