derickr / vld

BSD 2-Clause "Simplified" License
464 stars 87 forks source link

Vld raise a segment fault when i run this following script #33

Closed Ph0enixxx closed 6 years ago

Ph0enixxx commented 6 years ago

emmmm... it seems like a pointer problem.

script a.php:

<?php
#error_reporting(0);
$a = 12345;
function asd(){
    return 123111;
}
echo asd();
echo "123";
class AA{
    public function t(){echo 1236666;}
};
#eval($_GET['asd']);
eval("echo 123;");  // problem is here

$b = new AA();
$b->t();

run php with vld:

php -dvld.active=1 -dvld.execute=1  -S 0.0.0.0:8080

then run curl twice:

curl 127.0.0.1:8080/a.php?asd=echo 123;

the problem code is here:

static zend_op_array *vld_compile_string(zval *source_string, char *filename TSRMLS_DC)
{
    zend_op_array *op_array;

    op_array = old_compile_string (source_string, filename TSRMLS_CC);  // here

    if (op_array) {
        vld_dump_oparray (op_array TSRMLS_CC);

// #if defined(ZEND_ENGINE_3)
//      zend_hash_apply_with_arguments (CG(function_table) APPLY_TSRMLS_CC, (apply_func_args_t) vld_dump_fe_wrapper, 0);
//      zend_hash_apply (CG(class_table), (apply_func_t) vld_dump_cle_wrapper TSRMLS_CC);
// #else
//      zend_hash_apply_with_arguments (CG(function_table) APPLY_TSRMLS_CC, (apply_func_args_t) vld_dump_fe, 0);
//      zend_hash_apply (CG(class_table), (apply_func_t) vld_dump_cle TSRMLS_CC);
// #endif
    }

    return op_array;
}

how to fix it? My OS is OS X 10.12.6 PHP version is 7.1.16

derickr commented 6 years ago

This was a bug, and I've just merged a fix for this into the master Git branch.