Edit report at https://bugs.php.net/bug.php?id=71709&edit=1

 ID:                 71709
 Updated by:         c...@php.net
 Reported by:        kspen72 at gmail dot com
 Summary:            make test ext/curl/tests/curl_setopt_basic003.phpt
                     never completes
 Status:             Verified
 Type:               Bug
 Package:            Testing related
 Operating System:   Debian 3.2.73-2+deb7u2 x86_64
 PHP Version:        7.0.4
 Assigned To:        pierrick
 Block user comment: N
 Private report:     N

 New Comment:

> Using Debian 7.10 and 7.0.8 built with gcc 4.7.2, this minimal
> test case would crash:

I can reproduce this (same environment).

> Our fix was to edit the Makefile to compile ext/curl/interface.c
> with -O0.

`-O1` also works for me, and also `-O2 -fno-tree-tail-merge`.

Not sure if there's really an issue with -f-tree-tail-merge in gcc
4.7.2, but at least disabling this option might be a viable
workaround.


Previous Comments:
------------------------------------------------------------------------
[2016-07-26 02:52:16] chrisbolt at gmail dot com

Just to add another data point, we ran into this in our production environment, 
not just a test failure (see also https://bugs.php.net/bug.php?id=71703). Using 
Debian 7.10 and 7.0.8 built with gcc 4.7.2, this minimal test case would crash:

<?php
$ch = curl_init('http://www.google.com/');
curl_setopt($ch, CURLOPT_HTTPHEADER, array());
?>

Our fix was to edit the Makefile to compile ext/curl/interface.c with -O0.

------------------------------------------------------------------------
[2016-06-24 18:19:20] c...@php.net

I can confirm the issue on a bento/debian-7.10 vagrant box
with the official PHP 7.0.8. Running

  ./configure --disable-all --enabli-cli --with-curl
  make

and then running the test stalls. Setting a breakpoint on
_php_curl_setopt shows erratic program flow in gdb (might be due
to wrong macro expansion).

After

  make clean
  ./configure --disable-all --enabli-cli --with-curl --enable-debug
  make

the test runs as expected.

------------------------------------------------------------------------
[2016-06-24 13:03:03] c...@php.net

Thanks for the backtrace and for testing the patch. Indeed, there
appears to be something terribly wrong, because the segfault is
happening when PHP is processing curl_setopt(…,
CURLOPT_PROGRESSFUNCTION)[1], which is not supposed to happen
during this test. I'll try to reproduce the issue.

[1] <https://github.com/php/php-src/blob/php-7.0.8/ext/curl/interface.c#L2822>

------------------------------------------------------------------------
[2016-06-24 12:32:05] klaus dot keppler at googlemail dot com

Patch 71709 doesn't help, still crashing with SEGFAULT.

Error occurs at PHP line "curl_setopt($ch, CURLOPT_HTTPHEADER, array());"

------------------------------------------------------------------------
[2016-06-24 12:23:31] klaus dot keppler at gmail dot com

Ok, bug is 100% reproducible on Debian 7.11 with curl 7.26.0-1+wheezy13 and PHP 
7.0.8
Running the test script within the build tree triggers the segmentation fault.

We have two independent problems:
1.) if a single test crashes, the "make test" environment shouldn't stop. I 
don't know the details of the test system, but it looks like a SIGCHLD is not 
catched properly, leading to a zombie child.

2.) there's a bug/problem in the CURL module. I've pasted the detailed GDB 
output and backtrace below.

Best regards

   -Klaus


kk@debian7-amd64-build:/usr/src/php/php-7.0.8$ gdb sapi/cli/php
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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/src/php/php-7.0.8/sapi/cli/php...done.
(gdb) run ext/curl/tests/curl_setopt_basic003.phpt
Starting program: /usr/src/php/php-7.0.8/sapi/cli/php 
ext/curl/tests/curl_setopt_basic003.phpt
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
--TEST--
curl_setopt() call with CURLOPT_HTTPHEADER
--CREDITS--
Paul Sohier
#phptestfest utrecht
--SKIPIF--
--FILE--
*** curl_setopt() call with CURLOPT_HTTPHEADER
bool(false)

Program received signal SIGSEGV, Segmentation fault.
_zval_ptr_dtor (zval_ptr=0x4) at 
/usr/src/php/php-7.0.8/Zend/zend_execute_API.c:533
533             i_zval_ptr_dtor(zval_ptr ZEND_FILE_LINE_RELAY_CC);
(gdb) bt
#0  _zval_ptr_dtor (zval_ptr=0x4) at 
/usr/src/php/php-7.0.8/Zend/zend_execute_API.c:533
#1  0x00007ffff3d9e305 in _php_curl_setopt (ch=0x7ffff485c8c0, 
option=<optimized out>,
    zvalue=0x7ffff48132c0) at /usr/src/php/php-7.0.8/ext/curl/interface.c:2822
#2  0x00007ffff3d9f084 in zif_curl_setopt (execute_data=<optimized out>, 
return_value=0x7ffff48131d0)
    at /usr/src/php/php-7.0.8/ext/curl/interface.c:2984
#3  0x00000000006ef062 in ZEND_DO_ICALL_SPEC_HANDLER 
(execute_data=0x7ffff4813030)
    at /usr/src/php/php-7.0.8/Zend/zend_vm_execute.h:586
#4  0x00000000006dfb20 in execute_ex (ex=<optimized out>)
    at /usr/src/php/php-7.0.8/Zend/zend_vm_execute.h:417
#5  0x0000000000730517 in zend_execute (op_array=op_array@entry=0x7ffff487c000,
    return_value=return_value@entry=0x0) at 
/usr/src/php/php-7.0.8/Zend/zend_vm_execute.h:458
#6  0x00000000006a1ea4 in zend_execute_scripts (type=type@entry=8, 
retval=retval@entry=0x0,
    file_count=file_count@entry=3) at /usr/src/php/php-7.0.8/Zend/zend.c:1427
#7  0x0000000000643ab0 in php_execute_script 
(primary_file=primary_file@entry=0x7fffffffd8a0)
    at /usr/src/php/php-7.0.8/main/main.c:2494
#8  0x0000000000732000 in do_cli (argc=2, argv=0xf5f3a0)
    at /usr/src/php/php-7.0.8/sapi/cli/php_cli.c:974
#9  0x000000000043a66c in main (argc=2, argv=0xf5f3a0) at 
/usr/src/php/php-7.0.8/sapi/cli/php_cli.c:1344
(gdb)

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=71709


--
Edit this bug report at https://bugs.php.net/bug.php?id=71709&edit=1

-- 
PHP Quality Assurance Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to