Skip to content

socket_select overwriting its untyped by-ref array parameter leaks the caller's previous array on every call. #547

Closed

Description

@blacktrs

Summary

socket_select overwriting its untyped by-ref array parameter leaks the caller's previous array on every call.

Repro

<?php
socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $p);
$m0 = memory_get_peak_usage();
for ($i = 0; $i < 100000; $i++) {
    $r = array_fill(0, 64, $p[0]);
    $w = null;
    $e = null;
    socket_select($r, $w, $e, 0);
}
$mb = (memory_get_peak_usage() - $m0) >> 20;
fwrite(STDERR, "grew {$mb} MB\n");
echo $mb < 8 ? "flat\n" : "LEAK\n";

Expected (php)

flat

Actual (manticore 024071bf, Darwin arm64)

LEAK
(stderr: grew 63 MB)

Tracking

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

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

    bugleak

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions