Skip to content

Commit 0ce1cd1

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #81206: Multiple PHP processes crash with JIT enabled
2 parents 084d49a + ef77d3c commit 0ce1cd1

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

ext/opcache/ZendAccelerator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3199,7 +3199,7 @@ static zend_result accel_post_startup(void)
31993199
zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
32003200
return SUCCESS;
32013201
case SUCCESSFULLY_REATTACHED:
3202-
#if defined(HAVE_JIT) && !defined(ZEND_WIN32)
3202+
#ifdef HAVE_JIT
32033203
reattached = 1;
32043204
#endif
32053205
zend_shared_alloc_lock();

ext/opcache/jit/zend_jit.c

+23-17
Original file line numberDiff line numberDiff line change
@@ -4618,6 +4618,27 @@ ZEND_EXT_API void zend_jit_protect(void)
46184618
#endif
46194619
}
46204620

4621+
static void zend_jit_init_handlers(void)
4622+
{
4623+
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
4624+
zend_jit_runtime_jit_handler = dasm_labels[zend_lbhybrid_runtime_jit];
4625+
zend_jit_profile_jit_handler = dasm_labels[zend_lbhybrid_profile_jit];
4626+
zend_jit_func_hot_counter_handler = dasm_labels[zend_lbhybrid_func_hot_counter];
4627+
zend_jit_loop_hot_counter_handler = dasm_labels[zend_lbhybrid_loop_hot_counter];
4628+
zend_jit_func_trace_counter_handler = dasm_labels[zend_lbhybrid_func_trace_counter];
4629+
zend_jit_ret_trace_counter_handler = dasm_labels[zend_lbhybrid_ret_trace_counter];
4630+
zend_jit_loop_trace_counter_handler = dasm_labels[zend_lbhybrid_loop_trace_counter];
4631+
} else {
4632+
zend_jit_runtime_jit_handler = (const void*)zend_runtime_jit;
4633+
zend_jit_profile_jit_handler = (const void*)zend_jit_profile_helper;
4634+
zend_jit_func_hot_counter_handler = (const void*)zend_jit_func_counter_helper;
4635+
zend_jit_loop_hot_counter_handler = (const void*)zend_jit_loop_counter_helper;
4636+
zend_jit_func_trace_counter_handler = (const void*)zend_jit_func_trace_helper;
4637+
zend_jit_ret_trace_counter_handler = (const void*)zend_jit_ret_trace_helper;
4638+
zend_jit_loop_trace_counter_handler = (const void*)zend_jit_loop_trace_helper;
4639+
}
4640+
}
4641+
46214642
static int zend_jit_make_stubs(void)
46224643
{
46234644
dasm_State* dasm_state = NULL;
@@ -4637,23 +4658,7 @@ static int zend_jit_make_stubs(void)
46374658
}
46384659
}
46394660

4640-
if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
4641-
zend_jit_runtime_jit_handler = dasm_labels[zend_lbhybrid_runtime_jit];
4642-
zend_jit_profile_jit_handler = dasm_labels[zend_lbhybrid_profile_jit];
4643-
zend_jit_func_hot_counter_handler = dasm_labels[zend_lbhybrid_func_hot_counter];
4644-
zend_jit_loop_hot_counter_handler = dasm_labels[zend_lbhybrid_loop_hot_counter];
4645-
zend_jit_func_trace_counter_handler = dasm_labels[zend_lbhybrid_func_trace_counter];
4646-
zend_jit_ret_trace_counter_handler = dasm_labels[zend_lbhybrid_ret_trace_counter];
4647-
zend_jit_loop_trace_counter_handler = dasm_labels[zend_lbhybrid_loop_trace_counter];
4648-
} else {
4649-
zend_jit_runtime_jit_handler = (const void*)zend_runtime_jit;
4650-
zend_jit_profile_jit_handler = (const void*)zend_jit_profile_helper;
4651-
zend_jit_func_hot_counter_handler = (const void*)zend_jit_func_counter_helper;
4652-
zend_jit_loop_hot_counter_handler = (const void*)zend_jit_loop_counter_helper;
4653-
zend_jit_func_trace_counter_handler = (const void*)zend_jit_func_trace_helper;
4654-
zend_jit_ret_trace_counter_handler = (const void*)zend_jit_ret_trace_helper;
4655-
zend_jit_loop_trace_counter_handler = (const void*)zend_jit_loop_trace_helper;
4656-
}
4661+
zend_jit_init_handlers();
46574662

46584663
dasm_free(&dasm_state);
46594664
return 1;
@@ -4928,6 +4933,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, bool reattached)
49284933
#if _WIN32
49294934
/* restore global labels */
49304935
memcpy(dasm_labels, dasm_buf, sizeof(void*) * zend_lb_MAX);
4936+
zend_jit_init_handlers();
49314937
#endif
49324938
}
49334939

0 commit comments

Comments
 (0)