Bug #71977 [Opn]: After opcache turned on to cause Segmentation fault

From: Date: Fri, 08 Apr 2016 11:45:19 +0000
Subject: Bug #71977 [Opn]: After opcache turned on to cause Segmentation fault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200435@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=71977&edit=1

 ID:                 71977
 User updated by:    wangduo1122 at 163 dot com
 Reported by:        wangduo1122 at 163 dot com
 Summary:             After opcache turned on to cause Segmentation fault
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   Linux
 PHP Version:        7.0.5
 Block user comment: N
 Private report:     N

 New Comment:

If you turn off opcache, we would not have this problem.


Previous Comments:
------------------------------------------------------------------------
[2016-04-07 10:07:34] wangduo1122 at 163 dot com

The original function is accomplished , I do not want to modify the original function .
Test the "a/d", this will not be the original parameters to be modified.
Are there any other ways to solve this problem ?

------------------------------------------------------------------------
[2016-04-07 06:17:01] nikic@php.net

You must
a) declare the parameter as being by-reference in arginfo and
b) separate the argument by using "a/d" instead of "ad".

Does doing these two things fix the issue?

------------------------------------------------------------------------
[2016-04-06 13:48:26] wangduo1122 at 163 dot com

Description:
------------
When turned on opcache, the first call to extension function normally , the second appeared
Segmentation fault. Close opcache is normal.Through debug and found add_assoc_stringl,add_assoc_long
caused Segmentation fault when turned on opcache

Test script:
---------------
ZEND_FUNCTION( L5ApiGetRoute ){
    double d_time_out   = 0;
    std::string err_msg;
    zval *za_qos_req;

    if ( ZEND_NUM_ARGS() == 2 ){
        if ( zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"ad",&za_qos_req,&d_time_out) == FAILURE ){
            RETURN_LONG(-2);
    }else{
        WRONG_PARAM_COUNT;
        RETURN_LONG(-3);
    }
php_var_dump(za_qos_req, 1);
    add_assoc_stringl( za_qos_req, "hostIp", "10.175.90.28", 12);
    add_assoc_long( za_qos_req, "hostPort", 80 );
}

PHP code:
<?php
    $l5_req = array(
                'modId' => 64100225,
                'cmdId' => 65536
    );
    $l5_time_out = 0.2;
    $ret = L5ApiGetRoute($l5_req, $l5_time_out);
    print_r($l5_req);
    $l5_reqx = array(
                'modId' => 64000833,
                'key' => 3
    );
    $ret = L5ApiGetRoute($l5_reqx, $l5_time_out);
    print_r($l5_reqx);
?>

PHP.INI(opcache config)
zend_extension=opcache.so
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=10
opcache.fast_shutdown=1
opcache.enable_cli=1

Actual result:
--------------
[root@cweb_sports_api_new_10 ~/cl5/php/src]# /usr/local/qqwebsrv/php7/bin/php test.php
array(2) {
  ["modId"]=>
  int(64100225)
  ["cmdId"]=>
  int(65536)
}
Array
(
    [modId] => 64100225
    [cmdId] => 65536
    [hostIp] => 10.175.90.28
    [hostPort] => 80
)
array(2) {---------------------Get the correct parameters
  ["modId"]=>
  int(64000833)
  ["key"]=>
  int(3)
}
Array
(
    [modId] => 64000833
    [key] => 3
    [hostIp] => 10.175.90.28
    [hostPort] => 80
)
[root@cweb_sports_api_new_10 ~/cl5/php/src]# /usr/local/qqwebsrv/php7/bin/php test.php
array(2) {
  ["modId"]=>
  int(64100225)
  ["cmdId"]=>
  int(65536)
}
Array
(
    [modId] => 64100225
    [cmdId] => 65536
    [hostIp] => 10.175.90.28
    [hostPort] => 80
)
array(32696) {----------------------Did not get to the parameter
Segmentation fault (core dumped)


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



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


Thread (5 messages)

« previous php.bugs (#200435) next »