ext/opcache JIT: attempt to fix EPERM on unprotecting dasm buffer.#13351
ext/opcache JIT: attempt to fix EPERM on unprotecting dasm buffer.#13351devnexen wants to merge 18 commits intophp:PHP-8.2from
Conversation
despite disabling protection before mprotect call, we still get an EPERM with ZTS build we set all PROT*flags. removing typo in mapped segments (flag in the wrong place even tough the os most likely discard it).
|
I don't see how this affects MACOS/ZTS builds... |
f945d93 to
0214a22
Compare
|
cc @iluuu1994 when you have a moment, to double check if I ve done anything wrong in the CI's side. Thx. |
|
@devnexen You can see the error here: https://github.com/php/php-src/actions/runs/7826796920
|
92ba014 to
b6fc71e
Compare
Now, it seems arm64 picks up x86 setting (bison path). No idea yet maybe the job hash ? I ll look later .. |
|
@devnexen See https://github.com/php/php-src/pull/13299/files#diff-5634435a3b24e8a6d21e34340762047e16266acbedc19ecf829b9754de588d89, you didn't copy all changes from GH-13299. |
b6fc71e to
872b79d
Compare
f0aa9a0 to
91a13de
Compare
05b164f to
083ff0a
Compare
df8a1f6 to
d5f8f1c
Compare
|
|
@devnexen If I may ask, do we need to backport all of these changes? I was under the impression you merely wanted to test this change for 8.2. For warnings, you could have temporarily disabled |
Not necessarily I kept as separated commits on purpose to see which worths what. Ok for the CI change, at least we see the original change fix the issue on macos arm64. |
|
@devnexen Great! I don't mind back-porting CI. nightly.yml can be dropped, it has no effect on older branches. |
|
I understood, this PR attempts to fix MACOS-ARM64-ZTS builds. Also the PR needs to be cleaned up. It touches many unrelated files. I suspect. this is because of change of the base branch. |
|
Do PHP-8.2/3-MACOS-ARM64-ZTS builds also fail? (they are not covered by "nightly" workflow). |
The change done in However the other change should had been done only for arm64. I ll go back to it later.
I did not plan to push other changes, was just to display more data on CI. |
It seems like this is the real mistake. |
| #if defined(ZTS) && (!defined(__APPLE__) || !defined(__aarch64__)) | ||
| opts |= PROT_EXEC; | ||
| #endif |
There was a problem hiding this comment.
This disables EXEC permissions for all threads. Therefore other threads are going to crash while this one won't return the permissions back.
According to https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon we should use pthread_jit_write_protect_np() without mprotect(), but I wasn't able to make it work.
In my opinion the code should be changed in this way https://github.com/php/php-src/pull/13375/files
It seems pthread_jit_write_protect_supported_np() somehow returns false (on github actions).
May be we should set com.apple.security.cs.allow-jit entitlement...
I don't have access to Mac and I have no idea how to do this.
There was a problem hiding this comment.
I think it needs codesign (and probably a proper apple license).
There was a problem hiding this comment.
I think it needs
codesign(and probably a proper apple license).
Can you try this?
There was a problem hiding this comment.
will give it a try sometime today definitively.
See discussion in php#13351. Closes phpGH-13396
See discussion in php#13351. Closes phpGH-13396
Apple Silicon has stricter rules about rwx mmap regions. They need to be created using the MAP_JIT flag. However, the MAP_JIT seems to be incompatible with MAP_SHARED. ZTS requires MAP_SHARED so that some threads may execute code from a page while another writes/appends to it. We did not find another solution, other than completely disabling JIT for Apple Silicon + ZTS. See discussion in #13351. Co-authored-by: Peter Kokot <[email protected]> Fixes GH-13400 Closes GH-13396
Apple Silicon has stricter rules about rwx mmap regions. They need to be created using the MAP_JIT flag. However, the MAP_JIT seems to be incompatible with MAP_SHARED. ZTS requires MAP_SHARED so that some threads may execute code from a page while another writes/appends to it. We did not find another solution, other than completely disabling JIT for Apple Silicon + ZTS. See discussion in #13351. Co-authored-by: Peter Kokot <[email protected]> Fixes GH-13400 Closes GH-13396
despite disabling protection before mprotect call, we still get an EPERM with ZTS build we set all PROT*flags. removing typo in mapped segments (flag in the wrong place even tough the os most likely discard it).