|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80435 Bus Error compiling phar.phar on Apple M1
Submitted: 2020-11-27 20:59 UTC Modified: 2022-08-08 22:26 UTC
Avg. Score:4.9 ± 0.3
Reproduced:8 of 8 (100.0%)
Same Version:2 (25.0%)
Same OS:7 (87.5%)
From: cja987 at gmail dot com Assigned: kelunik (profile)
Status: Assigned Package: Compile Failure
PHP Version: 8.0Git-2020-11-27 (Git) OS: macOS 11
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: cja987 at gmail dot com
New email:
PHP Version: OS:


 [2020-11-27 20:59 UTC] cja987 at gmail dot com
Using the compile command shown in the test script below, compilation proceeds normally and it even builds some of the SAPIs, but once it gets to phar, things go sideways:

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
make: *** [ext/phar/phar.phar] Bus error: 10

Test script:
make distclean; ./buildconf && PATH=/opt/homebrew/opt/bison/bin:$PATH ./configure --with-iconv=/opt/homebrew/opt/libiconv && make -j10 YACC=/opt/homebrew/opt/bison/bin/bison

# The above shows another minor bug: I should not have to set YACC, 
# but the makefile sets it to just "bison" rather than the full path,
# which causes it to find the obsolete system bison in the path instead.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-27 21:01 UTC] cja987 at gmail dot com
As requested, these values from the makefile:

PHP_PHARCMD_SETTINGS = -n -d 'open_basedir=' -d 'output_buffering=0' -d 
'memory_limit=-1' -d phar.readonly=0

PHP_PHARCMD_BANG = `$(top_srcdir)/build/shtool echo -n -- "$(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)";`
 [2020-11-30 14:54 UTC]
I suspect the build might be entirely borked, and the phar generation is just the first part that actually uses the produced binary.

Does running `sapi/cli/php -v` work? If so, does running `sapi/cli/php run-tests.php Zend -j8` produce any failures?
 [2020-11-30 16:33 UTC] cja987 at gmail dot com
sapi/cli/php -v does work, but it does immediately get run over by the bus (error)  when running the test suite.  I can't convince gdb to install either, so there's not a lot that's debuggable.  Homebrew does build php successfully, and it appears it even applies a patch or two, so I'll work backwards from that.
 [2021-05-08 01:15 UTC] hao dot sun at arm dot com
In my Apple M1 machine, using the method mentioned in this link( would fix this bug.

$ brew install pcre2
$ ./configure --with-external-pcre=$(brew --prefix pcre2)
$ make
$ make test

Note: the link is in Japanese. you may need to translate it to English.
 [2022-08-08 21:28 UTC]
The current error I get building on M2 is this:

Fatal error: Uncaught InvalidArgumentException: RegexIterator::__construct(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /Users/kelunik/.php-build/release/ext/phar/phar.php:1145
Stack trace:
#0 /Users/kelunik/.php-build/release/ext/phar/phar.php(1145): RegexIterator->__construct(Object(RecursiveIteratorIterator), '/\\.svn/')
#1 /Users/kelunik/.php-build/release/ext/phar/phar.php(1089): PharCommand::phar_add(Object(Phar), 0, '/Users/kelunik/...', NULL, '/\\.svn/', Object(SplFileInfo), NULL, false)
#2 /Users/kelunik/.php-build/release/ext/phar/phar.php(225): PharCommand->cli_cmd_run_pack(Array)
#3 /Users/kelunik/.php-build/release/ext/phar/phar.php(2101): CLICommand->__construct(19, Array)
#4 {main}
  thrown in /Users/kelunik/.php-build/release/ext/phar/phar.php on line 1145
make: *** [ext/phar/phar.phar] Error 255

This is caused by Apple's default protection on Apple Silicon chips, see

It's been fixed in, which is contained in libpcre2 10.40. updates php-src to libpcre2 10.40, but only for the 8.2+.
 [2022-08-08 21:29 UTC]
-Assigned To: +Assigned To: kelunik
 [2022-08-08 22:26 UTC]
See for PHP 8.1.
 [2022-11-23 05:53 UTC] Daniel9895hah at gmail dot com
Thanks for the info I will try to figure it out for more.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 19:01:34 2024 UTC