Skip to content

Leak-check cases measure peak RSS, so one page of allocator noise fails them (return_ref_boxed_local_no_leak) #437

Closed

Description

@blacktrs

Summary

tests/aot/cases/return_ref_boxed_local_no_leak.php cannot tell a leak from allocator noise on Linux. It failed once on linux-amd64 (shard 3/4) in the CI run of PR #429 and passed on a re-run elsewhere (linux-arm64, both alpine rows, macOS).

Cause

On Linux memory_get_usage() and memory_get_peak_usage() both return VmHWM from /proc/self/status (src/Runtime/Stdlib/VarExtra.php), the peak resident set, not the live heap. The case asserts that the peak grows by less than 200000 bytes over 20000 calls. One page-granularity bump of the peak (heap top growth, transparent huge pages, allocator arena or trim behaviour) can cross 200 KB with nothing leaked.

Evidence

  • viaArr run 400000 times on arm64: delta 65536, flat.
  • Same case in a linux/amd64 container, native and sh runners: PASS; 120 runs of the compiled binary printed leak zero times; 20000 / 100000 / 400000 iterations show 0 growth after the first batch.
  • MIR for viaArr looks normal (ref_cell, array_lit, mem_own_local).

Proposal

Measure something that a real leak moves and noise does not: either live RSS / allocator bytes in use, or a loop count large enough that a per-iteration leak of the string (~50 bytes) dwarfs a few pages. The same pattern (memory_get_usage delta under a fixed threshold) is used by other *_no_leak and *_flat cases and should be reviewed together.

Acceptance

The case fails on a deliberately re-introduced leak of $y and passes 100 consecutive runs on linux-amd64.

Activity

  1. added
    bug
    on Oct 24, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions