Bug #71438 [Opn]: Segmentation fault encountered when building PHP 7 in QEMU MIPS chroot jail
| From: | ramsey@php.net | Date: | Mon, 25 Jan 2016 18:32:58 +0000 |
| Subject: | Bug #71438 [Opn]: Segmentation fault encountered when building PHP 7 in QEMU MIPS chroot jail | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198887@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71438&edit=1
ID: 71438
Updated by: ramsey@php.net
Reported by: ramsey@php.net
Summary: Segmentation fault encountered when building PHP 7
in QEMU MIPS chroot jail
Status: Open
Type: Bug
Package: Compile Failure
Operating System: Debian Wheezy
PHP Version: 7.0.2
Block user comment: N
Private report: N
New Comment:
I was able to get a core dump without using --enable-debug. The segmentation fault, as I said
earlier, occurs when generating phar.php towards the end of the make process. Here is my full
terminal output when using gdb to show the backtrace:
root@vagrant-ubuntu-trusty-64:/php-src/php-7.0.2# gdb /php-src/php-7.0.2/sapi/cli/php
qemu_php_20160125-182638_24981.core
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mips-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /php-src/php-7.0.2/sapi/cli/php...done.
[New LWP 24981]
Core was generated by `/php-src/php-7.0.2/sapi/cli/php -n -n -d open_basedir= -d output_buffering=0
-d'.
Program terminated with signal 11, Segmentation fault.
#0 0x0067b624 in _zval_get_long_func (op=0x8ec1b8, op@entry=<error reading variable: Cannot
access memory at address 0x76ffe2f4>) at /php-src/php-7.0.2/Zend/zend_operators.c:751
751 convert_object_to_type(op, &dst, IS_LONG, convert_to_long);
warning: not using untrusted file ".gdbinit"
(gdb) bt
#0 0x0067b624 in _zval_get_long_func (op=0x8ec1b8, op@entry=<error reading variable: Cannot
access memory at address 0x76ffe2f4>) at /php-src/php-7.0.2/Zend/zend_operators.c:751
Cannot access memory at address 0x76ffe2f4
(gdb)
Previous Comments:
------------------------------------------------------------------------
[2016-01-25 17:42:03] ramsey@php.net
This is odd. If I build PHP 7.0.2 with --enable-debug, it builds perfectly fine with no segmentation
fault. All other parameters of my build script remain the same.
If I build PHP 7.0.2 without --enable-debug, I get the segmentation fault.
I've updated my Gist to include the --enable-debug config option, but at this point, I'm
not sure how to generate a backtrace, if it builds fine with --enable-debug.
------------------------------------------------------------------------
[2016-01-25 04:15:00] laruence@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
------------------------------------------------------------------------
[2016-01-23 23:32:37] ramsey@php.net
Description:
------------
I am encountering a segmentation fault when attempting to build PHP 7.0.2 in a chroot jail that is
using QEMU to emulate a MIPS architecture.
Using the same script with identical settings and configuration, I am able to build PHP 5.4.45,
5.5.31, and 5.6.17 without any segmentation faults.
The segmentation fault occurs toward the end of the
make command, immediately after the
"Generating phar.php" line (see "Actual result" below for error output).
----------
For those wondering why I am building PHP in an emulated MIPS environment: I am creating Docker
images on which Travis CI runs tests for my ramsey/uuid library. I want to ensure consistent
generation of UUIDs on 64-bit, 32-bit, little-endian, and big-endian systems. If interested, see the
following:
* https://github.com/ramsey/uuid
* https://hub.docker.com/r/benramsey/ramsey-uuid/
* https://travis-ci.org/ramsey/uuid
Test script:
---------------
Here is a Gist that will allow you to reproduce this issue within a Vagrant VM:
https://gist.github.com/ramsey/8ba95a871c75c3aad820
See the comments at the top of the script, but in short, once you're ready to run the script in
the VM, you can run it like this to build different chroot jails with different PHP versions:
sudo ./php7-qemu-mips-build.sh 7.0.2 mips mips wheezy
sudo ./php7-qemu-mips-build.sh 5.6.17 mips mips wheezy
sudo ./php7-qemu-mips-build.sh 5.5.31 mips mips wheezy
The 7.0.2 version is the one where I am encountering the segmentation fault.
Actual result:
--------------
Generating phar.php
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/bin/bash: line 1: 23824 Segmentation fault (core dumped) if test -x
"/php-src/php-7.0.2/sapi/cli/php"; then /php-src/php-7.0.2/build/shtool echo -n --
"/php-src/php-7.0.2/sapi/cli/php -n"; if test "x" != "x"; then
/php-src/php-7.0.2/build/shtool echo -n -- " -d extension_dir=/php-src/php-7.0.2/modules";
for i in bz2 zlib phar; do if test -f "/php-src/php-7.0.2/modules/$i.la"; then .
/php-src/php-7.0.2/modules/$i.la; /php-src/php-7.0.2/build/shtool echo -n -- " -d
extension=$dlname"; fi; done; fi; else /php-src/php-7.0.2/build/shtool echo -n --
"/php-src/php-7.0.2/sapi/cli/php"; fi; -n -d 'open_basedir=' -d
'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d
'safe_mode=0' /php-src/php-7.0.2/ext/phar/build_precommand.php > ext/phar/phar.php
make: *** [ext/phar/phar.php] Error 139
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71438&edit=1