Skip to content

opcache JIT support improvements attempts on macOs. #8382

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

Conversation

devnexen
Copy link
Member

for cases when shared segments switch b/w R/W/X and R/X bits.

@devnexen devnexen force-pushed the macos_opcache_jit_protect_flags_fix_attempt branch 5 times, most recently from 036c348 to 17d924a Compare April 16, 2022 10:36
@devnexen devnexen marked this pull request as ready for review April 16, 2022 11:18
@ramsey ramsey added this to the PHP 8.2 milestone May 22, 2022
@devnexen devnexen requested a review from dstogov July 19, 2022 03:18
Comment on lines 4617 to 4618
pthread_jit_write_protect_np(0);
opts |= PROT_EXEC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need to call mprotect() after pthread_jit_write_protect_np() here and in zend_jit_protect(). Also see code alignment.

This probably should be changed into:

if (zend_write_protect) {
        pthread_jit_write_protect_np(0);
        return;
}
opts |= PROT_EXEC

Comment on lines 4919 to 4918
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
if (zend_write_protect) {
pthread_jit_write_protect_np(0);
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This denies execution.

@devnexen devnexen force-pushed the macos_opcache_jit_protect_flags_fix_attempt branch from 17d924a to 6735ac4 Compare July 19, 2022 07:14
Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see problems in source code, but I can't test this.
Please try to test running ''ab -t 300 -c 10 ...'' and simultaneously modifying/touching executed php scripts.

Comment on lines 4647 to 4648
pthread_jit_write_protect_np(1);
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alignment

Comment on lines 4915 to 4928
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
if (zend_write_protect) {
pthread_jit_write_protect_np(1);
}
#endif
if (mprotect(dasm_buf, dasm_size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) {
fprintf(stderr, "mprotect() failed [%d] %s\n", errno, strerror(errno));
}
} else {
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
if (zend_write_protect) {
pthread_jit_write_protect_np(1);
}
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the both new identical chunks may be merged above.

for cases when shared segments switch b/w R/W/X and R/X bits.
@devnexen devnexen force-pushed the macos_opcache_jit_protect_flags_fix_attempt branch from 6735ac4 to 5842ce5 Compare July 19, 2022 07:42
@devnexen devnexen closed this in 1416961 Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants