php7.0: segmentation fault running twig test suite

Bug #1548442 reported by Nish Aravamudan
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php7.0 (Ubuntu)
Fix Released
Undecided
Nish Aravamudan

Bug Description

While running the twig test suite during build, with php 7.0.3-5, we see:

PHPUnit 5.1.3 by Sebastian Bergmann and contributors.

    ....FF...................................................... 60 / 1172 ( 5%)
    ............................................................ 120 / 1172 ( 10%)
    ............................................................ 180 / 1172 ( 15%)
    ............................................................ 240 / 1172 ( 20%)
    ............................................................ 300 / 1172 ( 25%)
    ................................................
    Program received signal SIGSEGV, Segmentation fault.
    __memcpy_avx_unaligned ()
        at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:273
    273 ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S: No such file
    or directory.
    (gdb) bt
     #0 __memcpy_avx_unaligned ()
        at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:273
     #1 0x00000000004ad578 in memcpy (__len=18446744073709551614,
        __src=0x7ffff14500bc, __dest=0x7ffff179c390)
        at /usr/include/x86_64-linux-gnu/bits/string3.h:53
     #2 zend_string_init (persistent=0, len=18446744073709551614,
        str=0x7ffff14500bc "\303\237\343\201\224a")
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_string.h:159
     #3 php_pcre_split_impl (pce=pce@entry=0x11055f0,
        subject=0x7ffff14500b8 "\303\251\303\204\303\237\343\201\224a",
        subject_len=10, return_value=return_value@entry=0x7ffff361b240,
        limit_val=-1, flags=<optimized out>)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/ext/pcre/php_pcre.c:1808
     #4 0x00000000004ade8b in zif_preg_split (execute_data=<optimized out>,
        return_value=0x7ffff361b240)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/ext/pcre/php_pcre.c:1721
     #5 0x0000000000706f2a in dtrace_execute_internal (
        execute_data=<optimized out>, return_value=<optimized out>)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:107
     #6 0x000000000079af90 in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:844
     #7 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff361b070)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #8 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff361b070)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #9 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #10 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3619ff0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #11 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3619ff0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #12 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #13 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3619e80)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #14 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3619e80)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #15 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #16 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3619db0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #17 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3619db0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #18 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #19 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3619ca0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #20 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3619ca0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #21 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #22 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff36192e0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #23 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff36192e0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #24 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #25 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3619210)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #26 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3619210)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #27 0x00000000007089dc in zend_call_function
    (fci=fci@entry=0x7fffffff9ae0,
        fci_cache=fci_cache@entry=0x7fffffff9ab0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_execute_API.c:860
     #28 0x0000000000592a42 in zim_reflection_method_invokeArgs (
        execute_data=<optimized out>, return_value=0x7ffff3618e60)
        at
    /build/php7.0-JvcPYe/php7.0-7.0.3/ext/reflection/php_reflection.c:3348
     #29 0x0000000000706f2a in dtrace_execute_internal (
        execute_data=<optimized out>, return_value=<optimized out>)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:107
     #30 0x000000000079af90 in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:844
     #31 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3618c60)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #32 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3618c60)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #33 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #34 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3618470)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #35 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3618470)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #36 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #37 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3617880)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #38 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3617880)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #39 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #40 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3616e20)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #41 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3616e20)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #42 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #43 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3616840)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #44 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3616840)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #45 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #46 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3616260)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #47 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3616260)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #48 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #49 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3615c80)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #50 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3615c80)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #51 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #52 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3614640)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #53 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3614640)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #54 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #55 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3614220)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #56 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3614220)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #57 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #58 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3614130)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #59 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3614130)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #60 0x000000000079b0cd in ZEND_DO_FCALL_SPEC_HANDLER ()
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:800
     #61 0x000000000075687b in execute_ex (ex=ex@entry=0x7ffff3614030)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:414
     #62 0x0000000000706dc1 in dtrace_execute_ex
    (execute_data=0x7ffff3614030)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_dtrace.c:83
     #63 0x00000000007a9c57 in zend_execute (
        op_array=op_array@entry=0x7ffff3683000,
        return_value=return_value@entry=0x0)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend_vm_execute.h:458
     #64 0x0000000000717053 in zend_execute_scripts (type=type@entry=8,
        retval=retval@entry=0x0, file_count=file_count@entry=3)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/Zend/zend.c:1427
     #65 0x00000000006b7a60 in php_execute_script (
        primary_file=primary_file@entry=0x7fffffffcb10)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/main/main.c:2484
     #66 0x00000000007ab924 in do_cli (argc=4, argv=0xf68130)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/sapi/cli/php_cli.c:974
     #67 0x000000000046a1b4 in main (argc=4, argv=0xf68130)
        at /build/php7.0-JvcPYe/php7.0-7.0.3/sapi/cli/php_cli.c:1345

Revision history for this message
Nish Aravamudan (nacc) wrote :

The testcase that is sementation fauilting is 'split_utf8.test'.

Revision history for this message
Neal Gompa (ngompa13) wrote :

After working with Remi Collet to track down the issue, we've identified the problem to be with PCRE support, specifically with PCRE JIT. We reached this suspicion after Remi was able to run the tests successfully with his PHP7 SCL for Fedora 23 just fine with the JIT enabled, but it broke on CentOS 7.2 and Ubuntu Xenial.

I tested on Ubuntu Xenial php7.0-7.0.3-9 (from xenial-proposed) and CentOS 7.2 php70-php-7.0.3-1.el7.remi SCL (from Remi's repository).

On both systems, I did the following:

0. Installed the required php7 packages.
** Ubuntu Xenial: php7.0-{cli,json,xml,mbstring}
** CentOS 7.2 php70 scl: php70-php-{cli,json,xml,mbstring}

1. Downloaded Twig 1.24.0 tarball from GitHub (https://github.com/twigphp/Twig/archive/v1.24.0/Twig-1.24.0.tar.gz)

2. Untarred it and changed into the new Twig-1.24.0 directory.

3. Downloaded composer.phar ( https://getcomposer.org/composer.phar ) and phpunit.phar ( https://phar.phpunit.de/phpunit.phar )
4. Run composer to set up the Twig sources.
** Ubuntu Xenial: php7.0 composer.phar install
** CentOS 7.2 php70 scl: php70 composer.phar install

5. Run phpunit on the Twig sources.
** Ubuntu Xenial: php7.0 phpunit.phar -v
** CentOS 7.2 php70 scl: php70 phpunit.phar -v

With the default configuration, these both fail with a segmentation fault.

However, if I add "pcre.jit=0" to php.ini (/etc/php/7.0/cli/php.ini on Ubuntu Xenial, /etc/opt/remi/php70/php.ini for CentOS 7.2 php70 scl) and re-run the tests, they pass completely.

There are two solutions here:
1) Identify what Fedora's pcre package has that fixes it vs the Debian/Ubuntu package (Fedora sources available here: http://pkgs.fedoraproject.org/cgit/rpms/pcre.git/tree/?h=f23), as both are using pcre 8.38, though I don't know why the soversion differs...
2) Add "pcre.jit=0" to the php configuration.

I don't consider solution 2 to be valid unless we're okay with disabling PCRE JIT across the board.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in php7.0 (Ubuntu):
status: New → Confirmed
Revision history for this message
Nish Aravamudan (nacc) wrote :

This is an upstream bug in PHP7.0. We can drop our twig workaround (Bug 1544276) when we/Debian get the new release: https://bugs.php.net/bug.php?id=71659

Nish Aravamudan (nacc)
Changed in php7.0 (Ubuntu):
assignee: nobody → Nish Aravamudan (nacc)
Steve Langasek (vorlon)
Changed in php7.0 (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package php7.0 - 7.0.4-5ubuntu2

---------------
php7.0 (7.0.4-5ubuntu2) xenial; urgency=medium

  * debian/patches/0048-fix-bug-71659-pcre-segfault-in-twig-tests.patch:
    Replace bump regex with calculate_unit_length(). Closes LP:
    #1548442.
  * debian/patches/0049-backport-89a43425.patch: Fix incompatible
    pointers on 64-bit. Closes LP: #1558201.

 -- Nishanth Aravamudan <email address hidden> Wed, 16 Mar 2016 12:30:50 -0700

Changed in php7.0 (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.