Page MenuHomePhabricator

Cygwin PHP segfaults with arcanist
Open, Needs TriagePublic


Using arcanist with a cygwin PHP installation (and console) on Windows results in a segfault in the current master and stable branches.

029e5a7c2900b7a4f516ac7e7c1415b0c6500ed1 works fine,
7e677c27eccfeaaf15921e8edbbc8eb5f1951351 segfaults instantly, when simply calling arc.

From a babun console (babun installs/prepares a cygwin+zsh shell environment):
{ arcanist } HEAD » arc /cygdrive/d/projects/arcanist
[1] 3556 segmentation fault (core dumped) arc

{ arcanist } HEAD » cat php.exe.stackdump                           /cygdrive/d/projects/arcanist
Exception: STATUS_ACCESS_VIOLATION at eip=6E026247
eax=FFE45000 ebx=002879F0 ecx=00287AD0 edx=FFE44FFF esi=FFE45000 edi=FFE44FFF
ebp=00000000 esp=00287910 program=C:\Users\Klass\.babun\cygwin\bin\php.exe, pid 3556, thread main
cs=0023 ds=002B es=002B fs=0053 gs=002B ss=002B
Stack trace:
Frame     Function  Args
End of stack trace

The non existant stacktrace is not really helpful.

To me, it seems that the commit 7e677c27eccfeaaf15921e8edbbc8eb5f1951351 does not really introduce usage of new/other php features or extensions.
Amongst other things, a call to phutil_console_format is introduced, which is used earlier in the same file arcanist.php as well.

My colleague said he undid one line change and was able to verify it being the causing issue.

I know a PHP segfault should be reported to PHP or in this case probably cygwin package creator, but I won’t analyze this further nor look for where I would report such a thing.

Maybe this information will help you support other cases or maybe you want to work around this, or maybe someone even wants to report to cygwin php.

Event Timeline

ite-klass updated the task description. (Show Details)
ite-klass added a project: Arcanist.
ite-klass added a subscriber: ite-klass.

What reasons would you prefer using cygwin's php instead of a regular php for windows? Is it just the default/convenient php because it's packaged with cygwin and hooked into its environment settings?

Babun pre-installs cygwin PHP usable from the unix-style shell.
PHP extensions can be installed with pact install php-jsonc php-curl.
As for the native PHP builds, you’ll have to tamper with PATH and manual extraction/file permission for extraction.

Furthermore, when I tried to use native PHP, I was able to run it being in the arcanist/scripts folder and running php arcanist.php, but not when in another folder / when running bin/arc.
It failed to open/execute arcanist.php. I was not able to fix that.

Definitely want to use the babun shell though, and not windows cmd.exe, for obvious reasons.

The recommended way of running Arcanist under Windows is from either the command prompt or msysgit, which can be installed from, with the official PHP for Windows binaries installed in some directory and added to your PATH. Guidance on how to set up Arcanist on Windows can be found at

Supper for esoteric setups (in particular, I've never heard of Babun before, and I use a lot of UNIX tools on Windows) is unlikely to be provided by upstream. If you're not using the official PHP binaries, you should attempt to replicate the issue on the official PHP binaries. If you can't replicate the issue on the official binaries, then you should either switch to using the official binaries (follow the guide linked above), or report the issue to Cygwin and wait for a fix.

It should be noted that I used to use Cygwin, but dropped it in favour of Msysgit / native PHP precisely because of incompatibilities with the native Windows tools / environment which made it unfeasible to continue using it.

Experiencing the same problem in 'vanilla' cygwin

Does vanilla cygwin include its own PHP?

+1 for cygwin/babun support.

Has anyone reported these issues to their respective maintainers?

I have had this issue at work for awhile but I just happened to install fresh Cygwin at home and arcanist is working. I installed:

  • php 5.6.15-1
  • php-curl 5.6.15-1
  • php-json 1.3.9-1

I won't be back to work until next year but will plan to check again there. For completeness:

Back at work... I have the same php, php-curl, and php-json versions in Cygwin and I am still core dumping (with my questionable-or-worse distribution system I'm not sure what arcanist and libphutil versions). I then updated to arcanist b3e68c9 and libphutil adb8a9c and arc doesn't seg-fault anymore. So, it seems to me that the initial trigger has likely been removed from arcanist but the issue that made it a seg-fault instead of a nice stack trace I suppose is still there in the PHP packages.

For anyone having the babun/cygwin + arc issue, this is how I got around it:

  • Download official Windows PHP package
  • Copy php-ini-[development|production] to php.ini
  • Uncomment extension=php_curl.dll
  • Edit your shell's rc file (e.g. .bashrc or .zshrc):
    • Add your php directory to the PATH variable: export PATH=/cygdrive/c/php:$PATH
    • Add following shell alias: alias arc="php C:/Users/$USER/phabricator/arcanist/scripts/arcanist.php"
  • Open a new shell and run arc, you should see: Usage Exception: No command provided. Try 'arc help'.

This runs arcanist with Windows' php though, which means for example that ~/.arcrc lives inside %appdata%. Beware of the usual path mess when using Windows executables under babun/cygwin.