php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71438 Segmentation fault encountered when building PHP 7 in QEMU MIPS chroot jail
Submitted: 2016-01-23 23:32 UTC Modified: 2021-01-17 04:22 UTC
From: ramsey@php.net Assigned: cmb (profile)
Status: No Feedback Package: Compile Failure
PHP Version: 7.0.2 OS: Debian Wheezy
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 + 23 = ?
Subscribe to this entry?

 
 [2016-01-23 23:32 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-25 04:15 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2016-01-25 04:15 UTC] 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-25 17:42 UTC] ramsey@php.net
-Status: Feedback +Status: Open
 [2016-01-25 17:42 UTC] 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 18:32 UTC] ramsey@php.net
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)
 [2021-01-08 16:52 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-01-08 16:52 UTC] cmb@php.net
Is that still an issue with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-01-17 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 03:01:29 2024 UTC