Commit ff200c3
coderzhao
Fix Fix GH-22857: virtual property hook mis-primes SIMPLE_GET under FUNC_ARG
zend_std_read_property() primed the SIMPLE_GET property-hook cache-slot
bit after every successful hook invocation, regardless of which opcode
triggered the read. When the caller was ZEND_FETCH_OBJ_FUNC_ARG (which
dispatches into the FETCH_OBJ_R handler for by-value argument fetches
via ZEND_VM_TAIL_CALL, keeping EX(opline) pointing at the FUNC_ARG
opcode), a subsequent hook read of the same slot would take the
SIMPLE_GET fast path in zend_vm_def.h. That fast path pushes a hook
call frame and returns opline | ZEND_VM_ENTER_BIT, expecting the
caller to re-enter the VM to run the hook.
Function-mode JIT dispatches FETCH_OBJ_R via a specialised path in
zend_jit.c that emits an "if IP != opline+1, exit to VM" guard, but
FETCH_OBJ_FUNC_ARG falls into the generic zend_jit_handler path which
has no such guard. Once the cache slot is primed under a FUNC_ARG
opline, the JIT-compiled FUNC_ARG code continues straight into the
JIT-compiled SEND_FUNC_ARG before the hook has actually run. The
pending argument slot then holds an adjacent property's raw bytes,
typically surfacing as one of:
* ValueError: file_get_contents(): Argument #1 ($filename) must not
contain any null bytes
* TypeError: expected string, <adjacent class> given
* zend_mm_heap corrupted (SIGABRT)
All three symptoms have the same root cause.
Restrict priming of SIMPLE_GET to a plain ZEND_FETCH_OBJ_R opline,
mirroring the guard already used for SIMPLE_READ a few lines above.
Closes GH-22857.1 parent ff926db commit ff200c3
1 file changed
Lines changed: 29 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
| 43 | + | |
| 44 | + | |
48 | 45 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
57 | 51 | | |
58 | | - | |
59 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
60 | 71 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
0 commit comments