Skip to content

SplObjectStorage debug handler mismanages memory #18322

Closed

Description

@ndossche

Description

The following code:

<?php

$stor = new SplObjectStorage();
$obj = new stdClass;
$stor[$obj] = 1;

$tmp = $stor->__debugInfo();
$tmp2 = $tmp[array_key_first($tmp)];
unset($tmp); // Drop $tmp2 RC to 1
$tmp2[0]['obj'] = new stdClass;
var_dump($tmp2);

Resulted in this output:

A bunch of ASAN crap

But I expected this output instead:

Not that

The problem is that the code uses a hack rather than properly managing memory: Z_ARRVAL_P(&tmp)->pDestructor = NULL;...

PHP Version

8.3+

Operating System

No response

Activity

  1. self-assigned this
    on Apr 13, 2025
  2. added a commit that references this issue on Apr 14, 2025
    1424fdc
  3. added 2 commits that reference this issue on Apr 14, 2025
    6750387
    fc63a98
  4. added a commit that references this issue on Apr 14, 2025
    89e5f6c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions