Skip to content

The object returned by a closure call whose result is discarded ($k();) is not released at the statement: its destructor runs at shutdown #97

Closed

Description

@blacktrs

Summary

The object returned by a closure call whose result is discarded ($k();) is not released at the statement: its destructor runs at shutdown.

Repro

<?php
final class P { public function __destruct() { echo "dtor\n"; } }
$k = function (): P { return new P(); };
$k();
echo "after call\n";

Expected (php)

dtor
after call

Actual (manticore 9ef47219, Darwin arm64)

after call
dtor

Tracking

Known-bug repro: tests/aot/repro/wrong/discarded_closure_result_not_released.php — bash tests/aot/xfail.sh -k discarded_closure_result_not_released reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 5, 2026
  2. blacktrs commented on Oct 5, 2026

    @blacktrs
    ContributorAuthor

    Not fixed on ds on purpose: the release of a discarded call result is decided in InsertMemoryOps, which the ownership branch (ownership-2) replaces almost entirely. Re-check after that lands — the repro stays in tests/aot/repro/wrong/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions