Skip to content

Segmentation fault when resizing hash table iterator list while adding #16054

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$multi_array = array ('zero', array (1, 2, 3), 'two');
next($multi_array);
end($multi_array);
$multi_array[] = &$multi_array;
$fusion = $multi_array;
$v1=$definedVars[array_rand($definedVars = get_defined_vars())];
$ary = array(
    0 => array(
        (binary) "binary",
        "abc2",
        1,
    ),
    (binary) "binary" => array(
        2,
        "b",
        3 => array(
            4,
            "c",
        ),
        "4abc" => array(
            4,
            "c",
        ),
    ),
);
$it = new RecursiveTreeIterator(new RecursiveArrayIterator($fusion), 0);
foreach($it as $k => $v) {
}
?>

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

Activity

  1. cmb69 commented on Sep 25, 2024

    @cmb69
    Member

    Not sure if that's an engine issue, or some misuse by Spl. Anyhow, PHP-8.3 (and possibly older branches are affected as well).

  2. ndossche commented on Sep 25, 2024

    @ndossche
    Member

    Not sure if that's an engine issue, or some misuse by Spl.

    Let's be honest, we all know which one of the two it is ;)
    I can have a look at both these SPL issues if you're not already working on it.

  3. ndossche commented on Sep 25, 2024

    @ndossche
    Member

    This already corrupts the heap:

    <?php
    $multi_array = ['zero'];
    $multi_array[] =& $multi_array;
    $it = new RecursiveTreeIterator(new RecursiveArrayIterator($multi_array), 0);
    foreach($it as $k => $v) {
    }
  4. ndossche commented on Sep 25, 2024

    @ndossche
    Member

    Oh actually, this may be engine related for once...

  5. self-assigned this
    on Sep 25, 2024
  6. changed the title [-]Segmentation fault in Zend/zend_hash.c[/-] [+]Segmentation fault when resizing hash table iterator while adding[/+] on Sep 25, 2024
  7. changed the title [-]Segmentation fault when resizing hash table iterator while adding[/-] [+]Segmentation fault when resizing hash table iterator list while adding[/+] on Sep 25, 2024
  8. added a commit that references this issue on Sep 25, 2024
    fdd6ba6
  9. added 2 commits that reference this issue on Sep 25, 2024
    4b8a12d
    e035a95
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