[xdebug-dev] Bug 0000311: Segmentation Fault

From: <noreply[@]lists.xdebug.org>
Date: Thu, 4 Oct 2007 10:33:11 +0200

The following bug has been RESOLVED.
======================================================================
http://bugs.xdebug.org/bug_view_page.php?bug_id=0000311
======================================================================
Reporter: sherman
Handler: derick
======================================================================
Project: Xdebug
Bug ID: 311
Category: Debug client (console)
Reproducibility: always
Severity: crash
Priority: normal
Status: resolved
Operating System: gentoo
PHP Version: 5.2-dev
Xdebug Version: 2.0.0
Resolution: won't fix
======================================================================
Date Submitted: 2007-09-28 23:07 CEST
Last Modified: 2007-10-04 10:33 CEST
======================================================================
Summary: Segmentation Fault
Description:
I writing simple php extension. I have crash with bellow code. Segfault
occurs only with enebled xdebug:

[code]
ONPHP_METHOD(QuerySkeleton, where)
{
        zval *where, *whereLogic, *exp, *logic;
        
        if (
                zend_parse_parameters(
                        ZEND_NUM_ARGS() TSRMLS_CC,
                        "z|z",
                        &exp,
                        &logic
                )
                == FAILURE
        ) {
                WRONG_PARAM_COUNT;
        }
        
        if (
                Z_TYPE_P(logic) == IS_NULL
                || (ZEND_NUM_ARGS() == 1)
        ) {
                ZVAL_NULL(logic);
        }
        
        where = ONPHP_READ_PROPERTY(getThis(), "where");
        
        if (
                zend_hash_num_elements(Z_ARRVAL_P(where)) != 0
                && Z_TYPE_P(logic) == IS_NULL
        ) {
                zend_throw_exception_ex(
                        onphp_ce_WrongArgumentException,
                        0 TSRMLS_CC,
                        "you have to specify expression logic"
                );
                return;
        } else {
                if (
                        zend_hash_num_elements(Z_ARRVAL_P(where)) == 0
                        && Z_TYPE_P(logic) != IS_NULL
                ) {
                        ZVAL_NULL(logic);
                }
                
                whereLogic = ONPHP_READ_PROPERTY(getThis(), "whereLogic");
                
                if (Z_TYPE_P(logic) != IS_NULL)
                        add_next_index_zval(whereLogic, logic);
                else
                        add_next_index_null(whereLogic);
                
                add_next_index_zval(where, exp);
        }
        
        RETURN_ZVAL(getThis(), 1, 0);
}
[/code]

Segfault occurs in the branch:

zend_hash_num_elements(Z_ARRVAL_P(where)) != 0
                && Z_TYPE_P(logic) == IS_NULL
        ) {
                zend_throw_exception_ex(
                        onphp_ce_WrongArgumentException,
                        0 TSRMLS_CC,
                        "you have to specify expression logic"
                );
                return;
}

Exception does not throw.

Without xdebug code work correctly.

Full Version of class here:

http://svn.shadanakar.org/filedetails.php?repname=onPHP&path=%2Ftrunk%2Fext%2Fsrc%2Fcore%2FOSQL%2FQuerySkeleton.c&rev=4300

======================================================================

----------------------------------------------------------------------
 derick - 2007-10-04 10:33 CEST
----------------------------------------------------------------------
I will not debug your extension for you. If you can explain to me why (and
how) this is Xdebug's fault - please reopen.

Bug History
Date Modified Username Field Change
======================================================================
2007-09-28 23:07sherman New Bug
2007-09-28 23:07sherman Bug Monitored: sherman
2007-10-04 10:33derick Bugnote Added: 0000734
2007-10-04 10:33derick Assigned To => derick
2007-10-04 10:33derick Resolution open => won't fix
2007-10-04 10:33derick Status new => resolved
======================================================================
Received on Thu Oct 04 2007 - 10:33:12 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST