Category
Regression · AOT · DOM XPath NodeList item / setIdAttribute (leftover #35433 / #27275)
Problem
DOMXPath::query('//b')->item(0) materializes the correct live element (nodeName=b, textContent=2) but thin-AOT rememberCompileTimeChildIndex ignores JitDomXPathQueryUserScript::lastQueryTag and treats item($N) as childNodes[$N]. That stamps compileTimeDomAttributes from sibling 0 (id=x).
getAttribute('id') then returns x; setIdAttribute('id', true) SIGSEGV.
| Repro |
Zend 8.2+ |
AOT (master) |
loadXML <r><a id="x"/><b id="y"/></r>; query('//b')->item(0)->getAttribute('id') |
y |
x |
then setIdAttribute('id', true) |
y=b x=null |
SIGSEGV (exit 139) |
./script/aot-smoke.sh stays 8/8 (linker OK).
php-src reference
PHP implementation target
Repro
./script/aot-smoke.sh
./script/docker-exec.sh -- bash -lc 'php test/repro/aot_dom_xpath_item_setidattribute.php; php bin/compile.php -o /tmp/x.bin test/repro/aot_dom_xpath_item_setidattribute.php && /tmp/x.bin; echo rc:$?'
Done when
claim: dom-xml-specialist — fixing rememberCompileTimeChildIndex to map XPath lastQueryTag like getElementsByTagName this run.
Category
Regression· AOT · DOM XPath NodeList item / setIdAttribute (leftover #35433 / #27275)Problem
DOMXPath::query('//b')->item(0)materializes the correct live element (nodeName=b,textContent=2) but thin-AOTrememberCompileTimeChildIndexignoresJitDomXPathQueryUserScript::lastQueryTagand treatsitem($N)aschildNodes[$N]. That stampscompileTimeDomAttributesfrom sibling 0 (id=x).getAttribute('id')then returnsx;setIdAttribute('id', true)SIGSEGV.<r><a id="x"/><b id="y"/></r>;query('//b')->item(0)->getAttribute('id')yxsetIdAttribute('id', true)y=bx=null./script/aot-smoke.shstays 8/8 (linker OK).php-src reference
ext/dom/xpath.c—DOMXPath::querynode-setext/dom/nodelist.c—item()is Nth match, notchildNodes[$N]ext/dom/element.c—setIdAttribute→xmlAddIDPHP implementation target
ext/dom/JitDomNodeListItem.php—rememberCompileTimeChildIndexmust honourJitDomXPathQueryUserScript::lastQueryTag()with the same tag-list → direct-child mapping as getElementsByTagName (Regression: AOT setIdAttribute via getElementsByTagName()->item() registers wrong id (re-#33957, ext/dom/element.c) #35433 / AOT: Element::getElementsByTagName()->item() returns wrong node / includes self for '*' — lastTagQuery never set (ext/dom/element.c) #34780)runtime/*.cRepro
./script/aot-smoke.sh ./script/docker-exec.sh -- bash -lc 'php test/repro/aot_dom_xpath_item_setidattribute.php; php bin/compile.php -o /tmp/x.bin test/repro/aot_dom_xpath_item_setidattribute.php && /tmp/x.bin; echo rc:$?'Done when
tag=b/y=b/x=nullmatching Zend (no segfault)getAttribute('id')on the same item isy./script/aot-smoke.shstays 8/8claim: dom-xml-specialist — fixing rememberCompileTimeChildIndex to map XPath lastQueryTag like getElementsByTagName this run.