Skip to content

Commit ef77d3c

Browse files
committed
Fix #81206: Multiple PHP processes crash with JIT enabled
We need to avoid resetting the JIT for all SAPIs, but we need to initialize the JIT handlers even when only reattaching on Windows. Closes GH-7208.
1 parent 9d0fb10 commit ef77d3c

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PHP NEWS
1616
(Dmitry)
1717
. Fixed bug #81249 (Intermittent property assignment failure with JIT
1818
enabled). (Dmitry)
19+
. Fixed bug #81206 (Multiple PHP processes crash with JIT enabled). (cmb,
20+
Nikita)
1921

2022
- Standard:
2123
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3008,7 +3008,7 @@ static zend_result accel_post_startup(void)
30083008
zend_accel_error(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
30093009
return SUCCESS;
30103010
case SUCCESSFULLY_REATTACHED:
3011-
#if defined(HAVE_JIT) && !defined(ZEND_WIN32)
3011+
#ifdef HAVE_JIT
30123012
reattached = 1;
30133013
#endif
30143014
zend_shared_alloc_lock();

ext/opcache/jit/zend_jit.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,24 +4044,8 @@ ZEND_EXT_API void zend_jit_protect(void)
40444044
#endif
40454045
}
40464046

4047-
static int zend_jit_make_stubs(void)
4047+
static void zend_jit_init_handlers(void)
40484048
{
4049-
dasm_State* dasm_state = NULL;
4050-
uint32_t i;
4051-
4052-
dasm_init(&dasm_state, DASM_MAXSECTION);
4053-
dasm_setupglobal(&dasm_state, dasm_labels, zend_lb_MAX);
4054-
4055-
for (i = 0; i < sizeof(zend_jit_stubs)/sizeof(zend_jit_stubs[0]); i++) {
4056-
dasm_setup(&dasm_state, dasm_actions);
4057-
if (!zend_jit_stubs[i].stub(&dasm_state)) {
4058-
return 0;
4059-
}
4060-
if (!dasm_link_and_encode(&dasm_state, NULL, NULL, NULL, NULL, zend_jit_stubs[i].name, 0)) {
4061-
return 0;
4062-
}
4063-
}
4064-
40654049
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
40664050
zend_jit_runtime_jit_handler = dasm_labels[zend_lbhybrid_runtime_jit];
40674051
zend_jit_profile_jit_handler = dasm_labels[zend_lbhybrid_profile_jit];
@@ -4079,6 +4063,27 @@ static int zend_jit_make_stubs(void)
40794063
zend_jit_ret_trace_counter_handler = (const void*)zend_jit_ret_trace_helper;
40804064
zend_jit_loop_trace_counter_handler = (const void*)zend_jit_loop_trace_helper;
40814065
}
4066+
}
4067+
4068+
static int zend_jit_make_stubs(void)
4069+
{
4070+
dasm_State* dasm_state = NULL;
4071+
uint32_t i;
4072+
4073+
dasm_init(&dasm_state, DASM_MAXSECTION);
4074+
dasm_setupglobal(&dasm_state, dasm_labels, zend_lb_MAX);
4075+
4076+
for (i = 0; i < sizeof(zend_jit_stubs)/sizeof(zend_jit_stubs[0]); i++) {
4077+
dasm_setup(&dasm_state, dasm_actions);
4078+
if (!zend_jit_stubs[i].stub(&dasm_state)) {
4079+
return 0;
4080+
}
4081+
if (!dasm_link_and_encode(&dasm_state, NULL, NULL, NULL, NULL, zend_jit_stubs[i].name, 0)) {
4082+
return 0;
4083+
}
4084+
}
4085+
4086+
zend_jit_init_handlers();
40824087

40834088
dasm_free(&dasm_state);
40844089
return 1;
@@ -4353,6 +4358,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, zend_bool reattached)
43534358
#if _WIN32
43544359
/* restore global labels */
43554360
memcpy(dasm_labels, dasm_buf, sizeof(void*) * zend_lb_MAX);
4361+
zend_jit_init_handlers();
43564362
#endif
43574363
}
43584364

0 commit comments

Comments
 (0)