Skip to content

Leak: every thrown-and-caught exception leaks #25

Closed

Description

@blacktrs

Summary

Leak: every thrown-and-caught exception leaks.

Fix planned in the ownership redesign epic (PR #15, task 9: exception unwinding / finally). Tracking only.

Repro

<?php
function thr(int $i): void { throw new \RuntimeException(str_repeat('e', 200) . $i); }
$m0 = memory_get_peak_usage();
$k = 0;
for ($i = 0; $i < 100000; $i++) { try { thr($i); } catch (\RuntimeException $e) { $k++; } }
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 8 ? "flat\n" : "LEAK\n";

The repro measures its own peak RSS (memory_get_peak_usage()) around the loop and prints flat when it grew by less than 8 MB.

Expected (php 8.5)

flat

Actual (manticore 10affa68, macOS arm64)

LEAK
(stderr: grew 32 MB)

Tracking

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugleak

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions