[xdebug-dev] Bug 0000311: Segmentation Fault

From: <noreply[@]lists.xdebug.org>
Date: Fri, 28 Sep 2007 23:07:59 +0200

The following NEW bug has been ADDED.
======================================================================
http://bugs.xdebug.org/bug_view_page.php?bug_id=0000311
======================================================================
Reporter: sherman
Handler:
======================================================================
Project: Xdebug
Bug ID: 311
Category: Debug client (console)
Reproducibility: always
Severity: crash
Priority: normal
Status: new
Operating System: gentoo
PHP Version: 5.2-dev
Xdebug Version: 2.0.0
======================================================================
Date Submitted: 2007-09-28 23:07 CEST
Last Modified: 2007-09-28 23:07 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

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

Bug History
Date Modified Username Field Change
======================================================================
2007-09-28 23:07sherman New Bug
2007-09-28 23:07sherman Bug Monitored: sherman
======================================================================
Received on Fri Sep 28 2007 - 23:08:01 BST

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