]> granicus.if.org Git - php/commit
Convert numeric string array keys to integers correctly in JITted code
authorAlex Dowad <alexinbeijing@gmail.com>
Thu, 29 Oct 2020 21:10:04 +0000 (23:10 +0200)
committerAlex Dowad <alexinbeijing@gmail.com>
Fri, 30 Oct 2020 20:07:08 +0000 (22:07 +0200)
commitd44235acaeb4b2ec0c17a479d048652649e850a9
treedbc809733bccf667af9105b342893cf9e765bf56
parent904c1b6589b999a8e387215ac3c8fce9e4ab62a8
Convert numeric string array keys to integers correctly in JITted code

While fixing bugs in mbstring, one of my new test cases failed with a strange
error message stating: 'Warning: Undefined array key 1...', when clearly the
array key had been set properly.

GDB'd that sucker and found that JIT'd PHP code was calling directly into
`zend_hash_add_new` (which was not converting the numeric string key to an
integer properly). But where was that code coming from? I examined the disasm,
looked up symbols to figure out where call instructions were going, then grepped
the codebase for those function names. It soon became clear that the disasm I
was looking at was compiled from `zend_jit_fetch_dim_w_helper`.
Zend/tests/dim_assign_001.phpt [new file with mode: 0644]
Zend/tests/dim_assign_001.txt [new file with mode: 0644]
ext/opcache/jit/zend_jit_helpers.c