Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Lazy object reset with object destructor can lead to use-after-free

Aberta
#24,455 2 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
48/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
c, php
Domínio
backend

Direção de pesquisa

Start by reading Zend/zend_lazy_objects.c around zend_object_make_lazy at line 338, then compare the resetAsLazyGhost() and resetAsLazyProxy() paths with the related re-entrant destruction issue #22399. Reproduce with the supplied PHP snippet under AddressSanitizer; done means both reset methods avoid the heap-use-after-free.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Bug Status: Needs Triage
Description

Originally reported by @cnwangjihe.

The re-entrant property destruction issue reported in #22399 also affects ReflectionClass::resetAsLazyGhost() and ReflectionClass::resetAsLazyProxy().

The following code:

<?php

class Target {
    public ?Trigger $trigger = null;
}

class Trigger {
    public function __construct(private object $target) {}

    public function __destruct() {
        unset($this->target->trigger);
    }
}

$reflection = new ReflectionClass(Target::class);
$target = new Target();
$target->trigger = new Trigger($target);

$reflection->resetAsLazyGhost($target, static function (): void {});

Resulted in this output:

ERROR: AddressSanitizer: heap-use-after-free
zend_object_make_lazy Zend/zend_lazy_objects.c:338

But I expected this output instead:

PHP Version
PHP 8.4+
Operating System

No response

Linguagem predominante
C
Estrelas
40.7k
Forks
8.3k
Merge médio
2d 16h
PRs com merge (30d)
151

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de php/php-src

Todas as issues de php/php-src

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.