Skip to content

Internal iterator functions can't handle UNDEF properties #16905

Closed

Description

@YuanchengJiang

Description

The following code:

<?php
$dom = Dom\HTMLDocument::createFromString("<p>foo</p>", LIBXML_NOERROR);
$child = $dom->documentElement->appendChild($dom->createElement('html'));
$fusion = $child;
var_dump(reset($fusion));

Resulted in this output (JIT 1205):

/php-src/main/spprintf.c:376:14: runtime error: member access within null pointer of type 'zend_string' (aka 'struct _zend_string')

PHP Version

nightly

Operating System

ubuntu 22.04

Activity

  1. self-assigned this
    on Nov 23, 2024
  2. ndossche commented on Nov 23, 2024

    @ndossche
    Member

    Similar issue to that simplexml bug most likely.
    Reduced to the following, which also works on 8.2:

    <?php
    $dom = new DOMDocument;
    $child = $dom->appendChild($dom->createElement('html'));
    var_dump(reset($child));
  3. ndossche commented on Nov 23, 2024

    @ndossche
    Member

    Actually, it's more broad than only DOM.
    The reason it fails for DOM is because the get_properties handler is not implemented, returning an array of undef zvals.

    However, the following fails too:

    class X {
    	public int $a;
    }
    
    $x = new X;
    var_dump(reset($x));
    var_dump(current($x));
    var_dump(end($x));
  4. changed the title [-]Segmentation fault at main/spprintf.c:376 when reset dom child in JIT[/-] [+]reset(), current(), end() can't handle UNDEF properties[/+] on Nov 23, 2024
  5. changed the title [-]reset(), current(), end() can't handle UNDEF properties[/-] [+]Internal iterator functions can't handle UNDEF properties[/+] on Nov 23, 2024
  6. added a commit that references this issue on Nov 23, 2024
    ca79b10
  7. added a commit that references this issue on Nov 28, 2024
    e1b4534
  8. added 3 commits that reference this issue on Nov 28, 2024
    6a195bd
    3a80936
    c10f5ce
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