php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70773 Segmentation fault (core dumped)
Submitted: 2015-10-23 03:52 UTC Modified: 2015-11-01 04:22 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: svein at vip dot qq dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 7.0.0RC5 OS: Linux 2.6.33.15
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: svein at vip dot qq dot com
New email:
PHP Version: OS:

 

 [2015-10-23 03:52 UTC] svein at vip dot qq dot com
Description:
------------
I wrote a PHP extension function my_test:
PHP_FUNCTION(my_test)
{
    long type = 0;
    char *function_name = NULL;
    int   function_name_len = 0;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type 
            ,&function_name,&function_name_len) == FAILURE) 
        {
        zend_error(E_ERROR, "my_test zend_parse_parameters error");
        }
    RETURN_LONG(1);
}
when i call this function in a php file 
php crash with Segmentation fault (core dumped)

but
when i modify mytest to:
PHP_FUNCTION(my_test)
{
    long type = 0;
    char *function_name = NULL;
    int   function_name_len = 0;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type 
            ,&function_name,&function_name_len) == FAILURE) 
        {
        zend_error(E_ERROR, "my_test zend_parse_parameters error");
        }
}

or

PHP_FUNCTION(my_test)
{
    long type = 0;
    char *function_name = NULL;
    int   function_name_len = 0;
    RETURN_LONG(1);
}

php run ok 






Test script:
---------------
PHP_FUNCTION(my_test)
{
    long type = 0;
    char *function_name = NULL;
    int   function_name_len = 0;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &type 
            ,&function_name,&function_name_len) == FAILURE) 
        {
        zend_error(E_ERROR, "my_test zend_parse_parameters error");
        }
    RETURN_LONG(1);
}

Expected result:
----------------
ok 

Actual result:
--------------
Segmentation fault (core dumped)

Patches

my_test (last revision 2015-10-23 03:53 UTC by svein at vip dot qq dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-23 04:09 UTC] laruence@php.net
use:
  size_t   function_name_len = 0;
 [2015-10-23 12:22 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2015-11-01 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-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 19:03:46 2022 UTC