Skip to content

Commit e787d9a

Browse files
committed
GH-9370: Fix opcache jit protection bits.
Allow mprotect to occur, pthread_jit_write_np are just to allow mprotect flags to be used. Closes #9371.
1 parent 92c8e79 commit e787d9a

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fixed bug GH-9285 (Traits cannot be used in readonly classes).
1111
(kocsismate)
1212

13+
- Opcache:
14+
. Fixed bug GH-9371 (Crash with JIT on mac arm64)
15+
(jdp1024/David Carlier)
16+
1317
- Random:
1418
. Fixed bug GH-9415 (Randomizer::getInt(0, 2**32 - 1) with Mt19937
1519
always returns 1). (timwolla)

ext/opcache/jit/zend_jit.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4611,7 +4611,6 @@ ZEND_EXT_API void zend_jit_unprotect(void)
46114611
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
46124612
if (zend_write_protect) {
46134613
pthread_jit_write_protect_np(0);
4614-
return;
46154614
}
46164615
#endif
46174616
opts |= PROT_EXEC;
@@ -4645,7 +4644,6 @@ ZEND_EXT_API void zend_jit_protect(void)
46454644
#ifdef HAVE_PTHREAD_JIT_WRITE_PROTECT_NP
46464645
if (zend_write_protect) {
46474646
pthread_jit_write_protect_np(1);
4648-
return;
46494647
}
46504648
#endif
46514649
if (mprotect(dasm_buf, dasm_size, PROT_READ | PROT_EXEC) != 0) {

ext/opcache/shared_alloc_mmap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ static int create_segments(size_t requested_size, zend_shared_segment ***shared_
166166
#ifdef PROT_MAX
167167
flags |= PROT_MAX(PROT_READ | PROT_WRITE | PROT_EXEC);
168168
#endif
169+
#ifdef MAP_JIT
170+
flags |= MAP_JIT;
171+
#endif
169172
#if (defined(__linux__) || defined(__FreeBSD__)) && (defined(__x86_64__) || defined (__aarch64__))
170173
void *hint = find_prefered_mmap_base(requested_size);
171174
if (hint != MAP_FAILED) {

0 commit comments

Comments
 (0)