Skip to content

Internal iterator functions can't handle UNDEF properties #16905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
YuanchengJiang opened this issue Nov 23, 2024 · 2 comments
Closed

Internal iterator functions can't handle UNDEF properties #16905

YuanchengJiang opened this issue Nov 23, 2024 · 2 comments

Comments

@YuanchengJiang
Copy link

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

@nielsdos
Copy link
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));

@nielsdos
Copy link
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));

@nielsdos nielsdos changed the title Segmentation fault at main/spprintf.c:376 when reset dom child in JIT reset(), current(), end() can't handle UNDEF properties Nov 23, 2024
@nielsdos nielsdos changed the title reset(), current(), end() can't handle UNDEF properties Internal iterator functions can't handle UNDEF properties Nov 23, 2024
nielsdos added a commit to nielsdos/php-src that referenced this issue Nov 23, 2024
nielsdos added a commit that referenced this issue Nov 28, 2024
* PHP-8.2:
  Fix GH-16905: Internal iterator functions can't handle UNDEF properties
nielsdos added a commit that referenced this issue Nov 28, 2024
* PHP-8.3:
  Fix GH-16905: Internal iterator functions can't handle UNDEF properties
nielsdos added a commit that referenced this issue Nov 28, 2024
* PHP-8.4:
  Fix GH-16905: Internal iterator functions can't handle UNDEF properties
charmitro pushed a commit to wasix-org/php that referenced this issue Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants