Skip to content

Commit 5910e1d

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix #81679: Tracing JIT crashes on reattaching
2 parents 75b2973 + 49380b5 commit 5910e1d

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ PHP NEWS
3030
. Fixed bug GH-7765 (php_oci_cleanup_global_handles segfaults at second
3131
call). (cmb)
3232

33+
- OPcache:
34+
. Fixed bug #81679 (Tracing JIT crashes on reattaching). (cmb)
35+
3336
- Readline:
3437
. Fixed bug #81598 (Cannot input unicode characters in PHP 8 interactive
3538
shell). (Nikita)

ext/opcache/ZendAccelerator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ typedef struct _zend_accel_shared_globals {
269269
/* uninitialized HashTable Support */
270270
uint32_t uninitialized_bucket[-HT_MIN_MASK];
271271

272+
/* Tracing JIT */
273+
void *jit_traces;
274+
const void **jit_exit_groups;
275+
272276
/* Interned Strings Support (must be the last element) */
273277
zend_string_table interned_strings;
274278
} zend_accel_shared_globals;

ext/opcache/jit/zend_jit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5001,7 +5001,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, bool reattached)
50015001
#endif
50025002
}
50035003

5004-
if (zend_jit_trace_startup() != SUCCESS) {
5004+
if (zend_jit_trace_startup(reattached) != SUCCESS) {
50055005
return FAILURE;
50065006
}
50075007

ext/opcache/jit/zend_jit_trace.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,33 @@ static zend_always_inline const char *zend_jit_trace_star_desc(uint8_t trace_fla
4646
}
4747
}
4848

49-
static int zend_jit_trace_startup(void)
49+
static int zend_jit_trace_startup(zend_bool reattached)
5050
{
51-
zend_jit_traces = (zend_jit_trace_info*)zend_shared_alloc(sizeof(zend_jit_trace_info) * JIT_G(max_root_traces));
52-
if (!zend_jit_traces) {
53-
return FAILURE;
54-
}
55-
zend_jit_exit_groups = (const void**)zend_shared_alloc(sizeof(void*) * (ZEND_JIT_TRACE_MAX_EXITS/ZEND_JIT_EXIT_POINTS_PER_GROUP));
56-
if (!zend_jit_exit_groups) {
57-
return FAILURE;
51+
if (!reattached) {
52+
zend_jit_traces = (zend_jit_trace_info*)zend_shared_alloc(sizeof(zend_jit_trace_info) * JIT_G(max_root_traces));
53+
if (!zend_jit_traces) {
54+
return FAILURE;
55+
}
56+
zend_jit_exit_groups = (const void**)zend_shared_alloc(sizeof(void*) * (ZEND_JIT_TRACE_MAX_EXITS/ZEND_JIT_EXIT_POINTS_PER_GROUP));
57+
if (!zend_jit_exit_groups) {
58+
return FAILURE;
59+
}
60+
ZEND_JIT_TRACE_NUM = 1;
61+
ZEND_JIT_COUNTER_NUM = 0;
62+
ZEND_JIT_EXIT_NUM = 0;
63+
ZEND_JIT_EXIT_COUNTERS = 0;
64+
ZCSG(jit_traces) = zend_jit_traces;
65+
ZCSG(jit_exit_groups) = zend_jit_exit_groups;
66+
} else {
67+
zend_jit_traces = ZCSG(jit_traces);
68+
if (!zend_jit_traces) {
69+
return FAILURE;
70+
}
71+
zend_jit_exit_groups = ZCSG(jit_exit_groups);
72+
if (!zend_jit_exit_groups) {
73+
return FAILURE;
74+
}
5875
}
59-
ZEND_JIT_TRACE_NUM = 1;
60-
ZEND_JIT_COUNTER_NUM = 0;
61-
ZEND_JIT_EXIT_NUM = 0;
62-
ZEND_JIT_EXIT_COUNTERS = 0;
6376

6477
memset(&dummy_op_array, 0, sizeof(dummy_op_array));
6578
dummy_op_array.fn_flags = ZEND_ACC_DONE_PASS_TWO;

0 commit comments

Comments
 (0)