Composer segfault on multiple configurations

Richard H Lee ricardohenrylee@gmail.com
Mon May 22 19:54:00 GMT 2017


On 18/05/2017 08:42, Sky Diver wrote:
> I may compile php from cygports

Just in case Sky Diver or anyone else is interested in compiling php 
from Cygports, here are some simple steps to do so. It's not really 
difficult and most of the time it takes up is downloading the packages 
and compiling php. You'll probably want to do the compilation step 
during a lunch break or something.

If you just want to get a patched php running, just skip to the steps below.

But I'm also putting putting these instructions out here in case anyone 
wants to do some testing. The php devs asked for confirmation that (a) 
the bug exists and (b) this patch actually fixes it, before committing 
the patch.

The devs ask this as they have had problems setting up a dev environment 
for php. So they are unable recreate this bug or test the patch 
themselves. This is why I feel any Cygwin-specific patches for php 
should, for the moment be submitted to Cygwin rather than going to php.

To recreate the bug, create a 4096 bytes php file.
$ for i in $(seq 4096); do echo; done > test.php
Then execute it.
$ php test.php
This should immediately segfault. You can also test it through apache as 
there are two ways this bug can occur, through the php cli and through 
the apache php module. That is why the patch is against two different 
points in the source. By running apache in debug mode, you can see when 
the segfault occurs.
$ /usr/sbin/apachectl -X

Steps
=====

1. Install the php source from cygwin
Install php from the Cygwin installer as normal, except check the Src 
checkbox as well as the Bin checkbox.

2. cd into the source directory
$ cd /usr/src/php-7.0.19-1.src

3. Copy the attachments over in that directory
- dependencies
- php-7.0.19-page-size.patch
- php-cygport-page-size.patch

5. Install the dependencies
There are 59 packages required to build php with cygport, listed in the 
attachment "dependencies". You'll probably use the command line for this 
rather than manually pick out the packages by hand in Cygwin's setup. 
You can either use setup's command line -P option or apt-cyg.
I used apt-cyg, so for me I run:
$ xargs apt-cyg install < dependencies
It will take a while to download all these packages.

4. Patch the cygport file
$ patch < php-cygport-page-size.patch

6. Prepare the source for compilation
$ cygport php.cygport prep

7. Compile php
$ cygport php.cygport compile
Depending on your cpu, this will take a significant amount of time.

8. Install your compiled php into a staging directory
$ cygport php.cygport install

9. Copy the files over from staging into root
$ rsync -varlI php-7.0.19-1.x86_64/inst/. /

10. Rebase the dlls in cygwin
$ rebase-trigger full
Exit all Cygwin processes, command line and services.
Run Cygwin's setup to actually perform the rebase.

If you rerun "php test.php" you now should get 4096 newlines instead of 
a segfault.

Should the patch miss php 7.0.20 or whatever the next version of php is 
for Cygwin, you can rerun the steps and just change the path names in 
steps 2 and 9. But hopefully the path will be merged in by then.



-------------- next part --------------
diff --git a/Zend/zend_stream.c b/Zend/zend_stream.c
index 3fd7fa0..f5b9bea 100644
--- a/Zend/zend_stream.c
+++ b/Zend/zend_stream.c
@@ -30,7 +30,11 @@
 # if HAVE_UNISTD_H
 #  include <unistd.h>
 #  if defined(_SC_PAGESIZE)
+#   ifdef __CYGWIN__
+#    define REAL_PAGE_SIZE 4096
+#   else
 #    define REAL_PAGE_SIZE sysconf(_SC_PAGESIZE);
+#   endif
 #  elif defined(_SC_PAGE_SIZE)
 #    define REAL_PAGE_SIZE sysconf(_SC_PAGE_SIZE);
 #  endif
diff --git a/main/main.c b/main/main.c
index 01ed3a6..0909309 100644
--- a/main/main.c
+++ b/main/main.c
@@ -96,7 +96,11 @@
 # if HAVE_UNISTD_H
 #  include <unistd.h>
 #  if defined(_SC_PAGESIZE)
+#   ifdef __CYGWIN__
+#    define REAL_PAGE_SIZE 4096
+#   else
 #    define REAL_PAGE_SIZE sysconf(_SC_PAGESIZE);
+#   endif
 #  elif defined(_SC_PAGE_SIZE)
 #    define REAL_PAGE_SIZE sysconf(_SC_PAGE_SIZE);
 #  endif
-------------- next part --------------
--- php.cygport	2017-05-14 09:27:04.000000000 +0100
+++ php-new.cygport	2017-05-20 18:18:45.937823600 +0100
@@ -35,6 +35,7 @@
 	5.6.6-fix-libtoolize.patch
 	5.6.9-apache2handler-zts.patch
 	7.0.17-pcre-jit-off.patch
+	php-7.0.19-page-size.patch
 "
 
 DIFF_EXCLUDES="aclocal.m4 configure generated_lists libtool.m4 lt*.m4 ltmain.sh php_config.h.in php_version.h tests"
-------------- next part --------------
apache2-devel
c-client
cygport
libaspell-devel
libattr-devel
libcroco0.6-devel
libcurl-devel
libedit-devel
libenchant-devel
libfam-devel
libffi-devel
libgd-devel
libgdbm-devel
libglapi-devel
libgnutls-devel
libgs-devel
libgtk2.0-devel
libgts-devel
libguile1.8-devel
libguile2.0-devel
libgvc-devel
libhunspell-devel
libicu-devel
libidn2-devel
libisl-devel
libjasper-devel
libkrb5-devel
libLASi-devel
liblcms-devel
libllvm-devel
liblzo2-devel
libmcrypt-devel
libming-devel
libmpc-devel
libmpfr-devel
libnghttp2-devel
libnss-devel
libonig-devel
libopenjp2-devel
libopenjpeg-devel
libpng12-devel
libpoppler-devel
libpq-devel
libpsl-devel
libreadline-devel
librsvg2-devel
libsigsegv-devel
libsqlite3-devel
libssh2-devel
libsybdb-devel
libthai-devel
libtidy-devel
libtxc_dxtn-devel
libunistring-devel
libvoikko-devel
libwebp-devel
libxslt-devel
libzip-devel
recode
-------------- next part --------------

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list