Skip to content

Commit

Permalink
Fix pcre.jit on Apple Silicon
Browse files Browse the repository at this point in the history
This backports zherczeg/sljit#105. Relates to bug #80435, however, it doesn't solve the bus error on PHP 8.0, but PHP 8.1 builds fine now.

Closes GH-9279.
  • Loading branch information
kelunik authored and cmb69 committed Aug 31, 2022
1 parent 65619e8 commit f8b217a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -18,6 +18,9 @@ PHP NEWS
. Fixed bug #77780 ("Headers already sent..." when previous connection was
aborted). (Jakub Zelenka)

- PCRE:
. Fixed pcre.jit on Apple Silicon. (Niklas Keller)

- Streams:
. Fixed bug GH-9316 ($http_response_header is wrong for long status line).
(cmb, timwolla)
Expand Down
3 changes: 3 additions & 0 deletions ext/pcre/pcre2lib/sljit/sljitExecAllocator.c
Expand Up @@ -187,10 +187,13 @@ static SLJIT_INLINE void* alloc_chunk(sljit_uw size)
if (retval == MAP_FAILED)
return NULL;

#ifdef __FreeBSD__
/* HardenedBSD's mmap lies, so check permissions again */
if (mprotect(retval, size, PROT_READ | PROT_WRITE | PROT_EXEC) < 0) {
munmap(retval, size);
return NULL;
}
#endif /* FreeBSD */

SLJIT_UPDATE_WX_FLAGS(retval, (uint8_t *)retval + size, 0);

Expand Down

0 comments on commit f8b217a

Please sign in to comment.