Skip to content

Circular reference in ContextStorageNode #1584

@evan361425

Description

@evan361425

Describe your environment
PHP 8.2.28, but this bug should not relevant with PHP version.

Steps to reproduce
After detached ContextStorageNode, it will reference itself as the previous node:

if ($this === $this->head->node) {
    assert($this->previous !== $this);
    $this->head->node = $this->previous;
    $this->previous = $this;

    return $flags;
}

Which cause circular reference to holding the memory.

What is the expected behavior?

Use WeakReference to avoid it.

if ($this === $this->head->node) {
    assert($this->previous !== $this);
    $this->head->node = $this->previous;
    $this->previous = WeakReference::create($this);

    return $flags;
}

What is the actual behavior?
Causing memory leak if we holding the process longer.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions