Skip to content

Fix #81206: Multiple PHP processes crash with JIT enabled #7208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -3008,7 +3008,7 @@ static zend_result accel_post_startup(void)
zend_accel_error(ACCEL_LOG_FATAL, "Failure to initialize shared memory structures - probably not enough shared memory.");
return SUCCESS;
case SUCCESSFULLY_REATTACHED:
#if defined(HAVE_JIT) && !defined(ZEND_WIN32)
#ifdef HAVE_JIT
reattached = 1;
#endif
zend_shared_alloc_lock();
Expand Down
40 changes: 23 additions & 17 deletions ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -4044,24 +4044,8 @@ ZEND_EXT_API void zend_jit_protect(void)
#endif
}

static int zend_jit_make_stubs(void)
static void zend_jit_init_handlers(void)
{
dasm_State* dasm_state = NULL;
uint32_t i;

dasm_init(&dasm_state, DASM_MAXSECTION);
dasm_setupglobal(&dasm_state, dasm_labels, zend_lb_MAX);

for (i = 0; i < sizeof(zend_jit_stubs)/sizeof(zend_jit_stubs[0]); i++) {
dasm_setup(&dasm_state, dasm_actions);
if (!zend_jit_stubs[i].stub(&dasm_state)) {
return 0;
}
if (!dasm_link_and_encode(&dasm_state, NULL, NULL, NULL, NULL, zend_jit_stubs[i].name, 0)) {
return 0;
}
}

if (zend_jit_vm_kind == ZEND_VM_KIND_HYBRID) {
zend_jit_runtime_jit_handler = dasm_labels[zend_lbhybrid_runtime_jit];
zend_jit_profile_jit_handler = dasm_labels[zend_lbhybrid_profile_jit];
Expand All @@ -4079,6 +4063,27 @@ static int zend_jit_make_stubs(void)
zend_jit_ret_trace_counter_handler = (const void*)zend_jit_ret_trace_helper;
zend_jit_loop_trace_counter_handler = (const void*)zend_jit_loop_trace_helper;
}
}

static int zend_jit_make_stubs(void)
{
dasm_State* dasm_state = NULL;
uint32_t i;

dasm_init(&dasm_state, DASM_MAXSECTION);
dasm_setupglobal(&dasm_state, dasm_labels, zend_lb_MAX);

for (i = 0; i < sizeof(zend_jit_stubs)/sizeof(zend_jit_stubs[0]); i++) {
dasm_setup(&dasm_state, dasm_actions);
if (!zend_jit_stubs[i].stub(&dasm_state)) {
return 0;
}
if (!dasm_link_and_encode(&dasm_state, NULL, NULL, NULL, NULL, zend_jit_stubs[i].name, 0)) {
return 0;
}
}

zend_jit_init_handlers();

dasm_free(&dasm_state);
return 1;
Expand Down Expand Up @@ -4353,6 +4358,7 @@ ZEND_EXT_API int zend_jit_startup(void *buf, size_t size, zend_bool reattached)
#if _WIN32
/* restore global labels */
memcpy(dasm_labels, dasm_buf, sizeof(void*) * zend_lb_MAX);
zend_jit_init_handlers();
#endif
}

Expand Down