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 |