Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pointcut on certain internal functions causing "could not obtain parameters" #99

Open
yogeshpandey009 opened this issue Jun 29, 2016 · 3 comments

Comments

@yogeshpandey009
Copy link

<?php
aop_add_around('array_push()', 'aroundSystemCall');
function aroundSystemCall (AopJoinPoint $joinpoint) {
    echo "Called before invoking -> {$joinpoint->getFunctionName()} with args: ", print_r($joinpoint->getArguments(), true);
    return $joinpoint->process(); //Issue: crashing for some system functions
    // Workaround: to use call_user_func_array instead
    //return call_user_func_array($joinpoint->getFunctionName(), $joinpoint->getArguments());
}
$a = array();
array_push($a, "apple");
print_r($a);

Warning: array_push(): could not obtain parameters for parsing

Same error for mysql_query()
$ php -v
PHP 5.4.14 (cli) (built: Jun 27 2016 14:02:51) (DEBUG)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

@yogeshpandey009 yogeshpandey009 changed the title Pointcut on certain system functions causing "could not obtain parameters" Pointcut on certain internal functions causing "could not obtain parameters" Jul 6, 2016
@yogeshpandey009
Copy link
Author

Workaround: comment out zval_ptr_dtor(&obj->value) insde aop.c:get_aopJoinpoint()

if (Z_REFCOUNT_P(aop_object) == 1) {
    AopJoinpoint_object *obj = (AopJoinpoint_object *)zend_object_store_get_object(aop_object TSRMLS_CC);
    if (obj->value) {
        zval_ptr_dtor(&obj->value); // is causing ((zval**)ex->function_state.arguments)[-1] value corruption
    }

@juliens : Could you please share some proper fix for this issue.
Thanks!

@juliens
Copy link
Member

juliens commented Jul 7, 2016

Commenting out this line doesn't fix the issue.

Warning: array_push(): could not obtain parameters for parsing in /home/juliens/devext/c/AOP/tests/issues/array_push_around.php on line 5

The problem seems to be elsewhere.

@yogeshpandey009
Copy link
Author

yogeshpandey009 commented Jul 7, 2016

Oh sorry I forgot to mention. This fixes "before" pointcut for multiple executions of array_push()

<?php
aop_add_before('array_push()', 'beforeSystemCall');
function beforeSystemCall (AopJoinPoint $joinpoint) {
    echo "Called before invoking -> {$joinpoint->getFunctionName()} with args: ", print_r($joinpoint->getArguments(), true);
}
$a = array();
array_push($a, "apple");
array_push($a, "banana");
array_push($a, "mango");
print_r($a);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants