Skip to content

Memory leaks in SPL constructors #16604

Closed

Description

@DanielEScherzer

Description

The following code:

<?php

$traversable = new RecursiveArrayIterator( [] );
$obj = new RecursiveIteratorIterator( $traversable );
$obj->__construct( $traversable );

Resulted in this output:

[Fri Oct 25 19:55:20 2024]  Script:  '/var/www/html/doubleConstruct.php'
/usr/src/php/ext/spl/spl_iterators.c(597) :  Freeing 0x00007f8883202b40 (56 bytes), script=/var/www/html/doubleConstruct.php
[Fri Oct 25 19:55:20 2024]  Script:  '/var/www/html/doubleConstruct.php'
/usr/src/php/Zend/zend_objects_API.h(94) :  Freeing 0x00007f888324f480 (144 bytes), script=/var/www/html/doubleConstruct.php
[Fri Oct 25 19:55:20 2024]  Script:  '/var/www/html/doubleConstruct.php'
/usr/src/php/ext/spl/spl_array.c(1645) :  Freeing 0x00007f888325f200 (96 bytes), script=/var/www/html/doubleConstruct.php
=== Total 3 memory leaks detected ===

But I expected this output instead:

[none]

Other SPL classes with this issue

  • RecursiveTreeIterator
  • SplFileObject
  • SplTempFileObject

PHP Version

8.5-dev

Operating System

No response

Activity

  1. Girgias commented on Oct 25, 2024

    @Girgias
    Member

    Those would be fixed by #16480

  2. added 2 commits that reference this issue on Oct 25, 2024
    9f5b5e3
    a19029f
  3. added a commit that references this issue on Oct 25, 2024
    5d993e9
  4. Girgias commented on Oct 25, 2024

    @Girgias
    Member

    Please double-check this is still happening now that the PR has been merged.

  5. DanielEScherzer commented on Oct 26, 2024

    @DanielEScherzer
    MemberAuthor

    Still an issue for RecursiveIteratorIterator, RecursiveTreeIterator, and SplFileObject
    SplTempFileObject now throws an error for calling the constructor a second time, so that is fixed

  6. added a commit that references this issue on Nov 1, 2024
    6cc45b5
  7. added 2 commits that reference this issue on Nov 1, 2024
    886a528
    eaa2b61
  8. added 2 commits that reference this issue on Nov 1, 2024
    7a78ffc
    2b17168
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions